symfony: undefined method Doctrine_Collection::offset()

by prettyscripts on 2009-12-16 12:24:11

phpsymfony

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.

Tags: doctrine, offset, symfony

1 comment

Comment by josefina @ 2011-04-24 12:53:26
*****
Thank you!
In Doctrine, just make sure you are not calling execute()

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)