Search code examples
symfony1propel

Pagination - Symfony


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?


Solution

  • 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;