How to Limit the paginate in cakephp

前端 未结 5 1451
时光说笑
时光说笑 2021-01-17 23:58

How to Limit the paginate in cakephp ?

Assume that i have 400 records.
I need to get only 25 records from 50th record to 75th record and need to display 5 recor

5条回答
  •  无人共我
    2021-01-18 00:25

    You can set conditions for the pagination.

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

    EDIT:

    A solution from here:

    $this->paginate = array(
      'limit' => 20,
      'totallimit' => 1000
      );
    

    And then in the Model:

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

提交回复
热议问题