Limit total number of results in Pagination?
I have a paginated page where I have over 1000 database records. How do I limit the per page results to 20 AND have the total results limited to 1000?
Asked by TyCam, on 3/2/10
2 Answers
in your find you can also set 'limit' => 20 and for the limiting of 1000 something like this is needed
http://github.com/infinitas/infinitas/blob/dev/extensions/libs/controllers/components/infinitas.php#L176
its just checking the current limit set and making sure its less or
to the limit requested.
Answered by dogmatic69on 3/2/10
<< previous next >>
Your Answer
You can use Creole Wiki Syntax to format your text.
Tagged with
Rating
0
Viewed
360 times
Last Activity
on 3/2/10
Thanks for the responses, but after way too many hours, I think I've solved it on my own.
In the paginate array, I simply added my own made up variable like this:
$this->paginate = array(
'limit' => 20,
'totallimit' => 1000
);
And then in the model file, I added in the method:
public function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
if( isset($extra['totallimit']) ) return $extra['totallimit'];
}
And presto, it returns the number of results I want.
TyCam - on 3/2/10