Reputation: 1946
I have the following code:
public function executeList()
{
$c = new Criteria();
$c->setLimit(5);
$this->latest = ItemPeer::doSelectLatest($c);
}
Now I'd like to be able to use pagination with this, using sfPropelPager.
How could I use that with the code above, making sure It paginates results from the peer method?
Upvotes: 2
Views: 1989
Reputation: 1946
I got it working:
Code is as follows:
$pager = new sfPropelPager('Item', 10);
$pager->setPage($request->getParameter('page', 1));
$pager->setPeerMethod('doSelectLatest');
$pager->init();
$this->pager = $pager;
Upvotes: 3
Reputation: 36241
You don't have to set limit explicitly. sfPropelPager will do it for you.
Example:
$pager = new sfPropelPager(’Item’, 5);
$pager->setPage($request->getParameter('page', 1));
$pager->setPeerMethod('doSelectLatest');
$pager->setPeerCountMethod('doCountLatest');
$pager->init();
Upvotes: 4