微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何限制cakephp中的分页

如何限制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'];
  }

原文地址:https://www.jb51.cc/php/131195.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐