我有一個symfony 2項目中的多對多關係,我嘗試創建一個左連接,但我有一個錯誤。我讀過數百篇文章和文章,但找不到解決方案。希望你能幫助我弄清楚:)Symfony 2左加入多對多關係船得到InvalidPathExpression錯誤
在這裏的錯誤:
[語義錯誤] 0行,列162附近的 '用戶= U WHERE':錯誤:無效PathExpression。 StateFieldPathExpression或SingleValuedAssociationField預期。
這裏我的關係:
AdminBundle\Entity\KeywordNeed:
...
manyToMany:
users:
targetEntity: User
mappedBy: keywordNeeds
而其他實體:
AdminBundle\Entity\User:
...
keywordOffers:
targetEntity: AdminBundle\Entity\KeywordOffer
inversedBy: users
nullable: true
joinTable:
name: users_keywordoffer
joinColumns:
user_id:
referencedColumnName: id
inverseJoinColumns:
keywordoffer_id:
referencedColumnName: id
終於SQL請求我產生:
SELECT distinct u FROM AdminBundle\Entity\Network n
INNER JOIN AdminBundle\Entity\User u WITH n.startup = u
LEFT JOIN AdminBundle\Entity\KeywordOffer ko WITH ko.users = u
WHERE n.network = :oUser
AND (u.lastName like '%blabla%' OR u.firstName like '%blabla%' OR u.company like '%blablaa%')
AND ko in ('7','6')
感謝您的幫助