Yii中使用分页-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
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://scgulin.cn/article/jdeijd.html