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