Access field in a many-to-many staging table with DQL in the Doctrine

I have a model called ContentGroup and the other is Content with a many-to-many relationship between them.

The staging table has a field called Position. When I try to write a DQL query to retrieve all the content related to a ContentGroup, I cannot reference the position field using model aliases or related relations.

will anyone try this?

thanks!

+4
source share
1 answer

Consider an intermediate IntModel model.

Not 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(); 
0
source

Source: https://habr.com/ru/post/1299056/


All Articles