php - CakePHP pagination maximum limit not working -
i using cakephp 2.x. unable set maximum limit of record.
please check code:
app::uses('appcontroller', 'controller'); class broadcastscontroller extends appcontroller { public $components = array('paginator'); public function broadcast(){ $this->paginator->settings = array('limit' => 10, 'order' => array('broadcast.no_of_user' => 'desc'), 'group' => 'broadcast.broadcaster_id'); $popularrooms = $this->paginator->paginate('broadcast'); pr($popularrooms); //fetch 200 records $this->set('popularrooms', $popularrooms); } }
above pr($popularrooms);
getting 200 records want first 50 records , per page showing 10 records. using 'maxlimit'=>50
code same 'limit'=>50
. please me.
in case, can use 'extras' array in paginator setting
$this->paginator->settings = array('limit' => 10, 'max_record'=>50, 'order' => array('broadcast.no_of_user' => 'desc'), 'group' => 'broadcast.broadcaster_id');
in model or appmodel overiding paginatecount function
class broadcast extends appmodel { function paginatecount($conditions, $recursive, $extra) { $param = array_merge(compact('conditions', 'recursive'), $extra); $count = $this->find('count', $param); if (!empty($extra['max_record']) && $count > $extra['max_records']) { $count = $extra['max_record']; } return $count; } }
Comments
Post a Comment