|Can $object->getRelation() return a doctrine query ? [message #91955]
||Thu, 21 January 2010 14:16
Registered: May 2009
First i'm using Symfony 1.3 with Doctrine.
I already worked on several projects with symfony, and i notice something annoying.
When you call $object->getRelation(), it returns all linked objects as a Doctrine_Collection.
But i would often prefer to get a Doctrine_Query, to filter and get only some linked objects. And it seems i can't, i must create a new query for that in model.
// return all comments via the schema relation
$comments = $post->getComments();
// but what i want only published comments ?
// am i forced to override getComments() and all my
// "getRelations" methods in model ?
Can't we pass an argument in getter method to say that we'd like a Doctrine_Query instead of a Doctrine_Collection ?