[英]Access field in a many-to-many intermediate table with DQL in Doctrine
我有一個名為ContentGroup的模型和另一個名為Content的模型,它們之間具有多對多的關系。
中間表有一個名為Position的字段,當我嘗試編寫DQL查詢以獲取與ContentGroup相關的所有內容時,我無法引用位置字段來使用所涉及的模型或關系的別名。
有人試試這個嗎?
謝謝!
考慮中間模型IntModel
。
沒有測試,但這應該工作:
$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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.