如何限制cakephp中的paginate

AnN*_*LaI 9 cakephp cakephp-1.3 cakephp-1.2

如何限制cakephp中的paginate?

假设我有400条记录.
我需要从第50条记录到第75条记录中只获得25条记录,并且每页需要显示5条记录.
我怎么能在分页中做到这一点?

示例代码:

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

            );
Run Code Online (Sandbox Code Playgroud)

paw*_*ior 10

您可以为分页设置条件.

function listRecords()
  {
  $this->paginate = array(
    'conditions' => array('Model.id >=' => 50, 'Model.id <=' => 75),
    'limit' => 5
    );
  $this->paginate('Model');
  );
Run Code Online (Sandbox Code Playgroud)

编辑:

这里的解决方案:

$this->paginate = array(
  'limit' => 20,
  'totallimit' => 1000
  );
Run Code Online (Sandbox Code Playgroud)

然后在模型中:

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