如何限制cakephp中的分页

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了如何限制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'];
  }

脚本宝典总结

以上是脚本宝典为你收集整理的如何限制cakephp中的分页全部内容,希望文章能够帮你解决如何限制cakephp中的分页所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。