symfony: undefined method Doctrine_Collection::offset()

by prettyscripts on 2009-12-16 12:24:11 • Leave a comment »

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

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
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 />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)