Monday, November 22, 2010

symfony: undefined method Doctrine_Collection::offset()

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:
 
$this->pager->setQuery($this->getResult()); // you should return QUERY, not fetched array

Be sure you are returning from getReult() method query, not fetched array.
$q = Doctrine_Query::create()->from('Model m'); 
return $q;

No comments:

Post a Comment