Hello,
On my application, i frequently do doctrine query like this :
$coms = Doctrine_Core::getTable('Comment')
->createQuery('c')
->join('c.article a')
->join('a.Writter w')
->where('w.something = ?', $something);
I want to extract the comments from articles with a condition on the writter. Le query start from the Comment Table ( because finally, we want a doctrine collection of Comment ), next i join to all the articles and then to all the writters. Finally, i make a restriction with the condition on the writters.
This query could be more optimized with the joints in this order :
$coms = Doctrine_Core::getTable('Writter')
->createQuery('w')
->select('c.*')
->join('w.Article a')
->join('a.Comments c')
->where('w.something= ?', $something);
Like this, the number of lines manipulated by the joints is much more reduced., because the restriction on the writter is made at first.
But with this code, i got an error :
The root class of the query (alias w) must have at least one field selected.
Does a solution exist to keep this order in joints and obtain finally a doctrine collection of Comment ?
Merci !