加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何限制cakephp中的分页

发布时间:2020-12-13 13:13:13 所属栏目:PHP教程 来源:网络整理
导读:如何限制cakephp中的分页? 假设我有400条记录. 我只需要25记录从第50记录到第75记录 并需要每页显示5条记录. 我如何在分页中做到这一点? 示例代码: $this-paginate = array( 'contain'=array('User'),'recursive' = 2,'order' = array('Profile.winning'
如何限制cakephp中的分页?

假设我有400条记录.
我只需要25记录从第50记录到第75记录
并需要每页显示5条记录.
我如何在分页中做到这一点?

示例代码:

$this->paginate = array(
                'contain'=>array('User'),'recursive' => 2,'order' => array('Profile.winning' => 'DESC'),'limit' =>5

            );
您可以为分页设置条件.
function listRecords()
  {
  $this->paginate = array(
    'conditions' => array('Model.id >=' => 50,'Model.id <=' => 75),'limit' => 5
    );
  $this->paginate('Model');
  );

编辑:

here的解决方案

$this->paginate = array(
  'limit' => 20,'totallimit' => 1000
  );

然后在型号:

public function paginateCount($conditions = null,$recursive = 0,$extra = array())
  {
  if( isset($extra['totallimit']) ) return $extra['totallimit'];
  }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读