Yii中使用分页

  1. Controller中的代码:

    我们提供的服务有:网站建设、成都做网站、微信公众号开发、网站优化、网站认证、新平ssl等。为近1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的新平网站制作公司

public function actionIndex(){

    $categoryModel = Category::model();

    $criteria = new CDbCriteria();

    $criteria->order = 'id ASC';

    $criteria->addCondition('status=1');      //根据条件查询

    $count = Category::model()->count($criteria);

    $pager = new CPagination($count);

    $pager->pageSize=2;

    $pager->applyLimit($criteria);

    $categoryInfo = Category::model()->findAll($criteria);

    $this->render('index',array('pages'=>$pager,'categoryInfo'=>$categoryInfo));

}

2. view视图中的调用:

widget('CLinkPager',array(

    'header' => '',

    'firstPageLabel' => '首页',

    'lastPageLabel' => '最后一页',

    'prevPageLabel' => '上一页',

    'nextPageLabel' => '下一页',

    'pages' => $pages,

    'maxButtonCount'=>3,

));?>

参考: http://www.yiichina.com/code


网页标题:Yii中使用分页
网站网址:http://lszwz.com/article/jdeijd.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款