成都创新互联网站制作重庆分公司

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://cxhlcq.com/article/jdeijd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部