i am trying to use the pagination concept in Cakephp for my application ..
var $paginate = array(
'limit' => 5,
'order' => array(
'Report.report_id' => 'desc'
)
);
ANd in the cakephp action
$conditions=array('Report.user_id'=>$userId);
$this->paginate['Report']['conditions']=$conditions;
$this->paginate['Report']['group']='Report.report_id';
$this->paginate['Report']['limit']=5;
$allreports=$this->paginate('Report');
Now this gives me the actual 5 entries of the Query with the group by condition but i m not getting the page numbers now in the View..
in the View
i have used like
<?php echo $paginator->numbers(); ?>
but it doesnt displays anything ?? why so.. guide me…
Best Solution
Although
Model::find()
supports thegroup
parameter, support for it has not been implemented for pagination. If you pass agroup
into$paginate
, although it will return the correct results, it will return an inconsistent recordCOUNT
(used to determine the number of pages). There is a ticket to add support for this but it won't be implemented until CakePHP 2.x. In the meantime, you will have to overridepaginateCount()
in your model as outlined in the examples under Custom Query Pagination in the manual.