views:

178

answers:

1

i have a model called ContentGroup and another called Content with a many-to-many relation between them.

The intermediate table has a field called Position, When i try to write a DQL query to obtain all the contents associated with a ContentGroup i cannot reference the position field usign the aliases of the models or relations involved.

someone try this?

thanks!

A: 

Consider intermediate model IntModel.

Didn't tested, but this should work:

$q = Doctrine::getTable('IntModel')->createQuery('p')
     ->leftJoin('p.Content as c')
     ->leftJoin('p.ContentGroup as cg')
     ->where('cg.id = ?', $my_content_group_id)->fetchOne();
echo $q->getPosition();
Darmen