How to paginate a different model with options in CakePHP

Assume you are on a LogsController which has Log as the default model and wanted to paginate another model LogColumn. Here’s How it goes:

cake-php-group-by-pagination

$this->paginate = array(
‘LogColumn’ => array(
‘limit’ => 20,
‘recursive’ => 0,
‘model’ => ‘LogColumn’,
‘order’ => array(‘LogColumn.id’ => ‘ASC’)
)
);

Now make the call with the options set already.

$log_columns = $this->Paginator->paginate(‘LogColumn’, array(‘LogColumn.log_id’=>$log_id));

Leave a Reply

Your email address will not be published.