Yii 中使用分页

发布时间:2020-06-17 10:22:36 作者:neptunecai
来源:网络 阅读:286
  1. Controller中的代码:

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视图中的调用:

<?php $this->widget('CLinkPager',array(

    'header' => '',

    'firstPageLabel' => '首页',

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

    'prevPageLabel' => '上一页',

    'nextPageLabel' => '下一页',

    'pages' => $pages,

    'maxButtonCount'=>3,

));?>


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

推荐阅读:
  1. yii2.0表格排序的方法
  2. Yii 框架如何使用数据库-databases

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php yii

上一篇: MFC 一个新的全局变量的定义

下一篇:博达3616系列OLT河北广电Qinq配置

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》