如何限制cakephp中的分页 [英] How to Limit the paginate in cakephp
本文介绍了如何限制cakephp中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何限制cakephp中的分页?
How to Limit the paginate in cakephp ?
假设我有400条记录。
我需要从第50条记录到第75条记录只有25条记录
,需要显示每页5条记录。
我如何在分页中执行此操作?
Assume that i have 400 records.
I need to get only 25 records from 50th record to 75th record
and need to display 5 records per page.
How i can do this in paginate ?
示例代码:
$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');
);
EDIT:
a href =http://ask.cakephp.org/questions/view/limit_total_number_of_results_in_pagination>此处:
$this->paginate = array(
'limit' => 20,
'totallimit' => 1000
);
然后在模型中:
public function paginateCount($conditions = null, $recursive = 0, $extra = array())
{
if( isset($extra['totallimit']) ) return $extra['totallimit'];
}
这篇关于如何限制cakephp中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文