by prettyscripts on 2009-12-16 12:24:11 • Leave a comment »
i got the following error when paginating results with sfDoctrinePager:
Fatal error: Call to undefined method Doctrine_Collection::offset() in /path/to/symfony/lib/plugins/sfDoctrinePlugin/lib/pager/sfDoctrinePager.class.php on line 84
if you're like me you'll think there's something wrong with symfony and search all over google and couldn't find anything.
this is not an error in symfony but could be in your own code.
in module action.class.php:
PHP:
public function executeIndex(sfWebRequest $request) | |
$this->pager = new sfDoctrinepager( | |
'Module', | |
sfConfig::get('app_max_results') | |
); | |
$this->pager->setQuery($this->getResult()); // note this | |
$this->pager->setPage($request->getParameter('page', 1)); | |
$this->pager->init(); | |
} |
note line 6: make sure the function calling from setQuery() is correct – that it returns query, not anything else.