Doctrine 2: limit by array of entities or bind an array
I know there is the CollectionMemberExpression
and of course IN
. What I need to do is find a number of users who are members of x teams.
SELECT u from NAMESPACE\User u LEFT JOIN u.开发者_如何学运维teams t WHERE t.team_id IN(?1)
or
SELECT u from NAMESPACE\User u LEFT JOIN u.teams t WHERE ?1 MEMBER OF t.teams
I can use a simple IN()
, and while I won't ever get any dirty items, I still like to bind whenever possible. At the DBAL level you can attach an array of strings/int, saving one from the hideous implode(',', $ids)
. Can this be done at the ORM level, setParameter(1, array);
So far it looks as though the implode
will be the way but would really like a better approach.
Thanks in advance.
精彩评论