I have a user and I want to check if it is in the qstn users relationship. I tried to execute the following DQL:
SELECT exmpl, qstn
FROM Foo\BarBundle\Entity\Examples exmpl
LEFT JOIN exmpl.question qstn
LEFT JOIN qstn.users u
WHERE :user IN (qstn.users)
But gave me the an error:
[Syntax Error] line 0, col 391: Error: Expected Literal, got 'qstn'
Is this even possible? If no, is there a work around (the doctrine way), not to nasty? (Not passing the users pre handed I could figure that out).
For ex NOT this: https://stackoverflow.com/a/22230515/2535171
You just need one more join
SELECT exmpl, qstn
FROM Foo\BarBundle\Entity\Examples exmpl
LEFT JOIN exmpl.question qstn
LEFT JOIN qstn.users u
WHERE u.id = :userID
It appears you can use the DQL keyword "MEMBER OF" ex:
SELECT exmpl, qstn
FROM Foo\BarBundle\Entity\Examples exmpl
LEFT JOIN exmpl.question qstn
LEFT JOIN qstn.users u
WHERE :user MEMBER OF qstn.users
I hope this helps someone!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.