2010-01-22 26 views
4

我有一個名爲ContentGroup的模型,另一個名爲Content的模型,它們之間有多對多的關係。DQL在Doctrine中的多對多中間表中的訪問字段

中間表有一個名爲位置的字段,當我嘗試寫一個DQL查詢以獲取與ContentGroup相關聯的所有內容時,我無法引用位置字段使用模型或涉及的關係的別名。

有人試過嗎?

謝謝!

回答

0

考慮中間模型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(); 
相關問題