Custom pagination finder in cakephp 1.2
Created: 2008-01-10 10:27:01, last updated: 2008-01-10 10:32:29
Yesterday, while talking about Cake's pagination with Gnuget, we found that before calling findAll with our conditions, the paginate() method of the controller checks if a method called paginate exists in the paginated model.
if (method_exists($object, 'paginate')) { $results = $object->paginate($conditions, $fields, $order, $limit, $page, $recursive); } else { $results = $object->findAll($conditions, $fields, $order, $limit, $page, $recursive); }This means that we could create a custom method in our model that receives the following parameters:
function paginate($conditions, $fields, $order, $limit, $page, $recursive) { // Our code goes here }
We must take into account that we should manually filter the results in our custom query by using $limit and $page.
0 comments