开发者

Doctrine 2: limit by array of entities or bind an array

开发者 https://www.devze.com 2023-03-07 17:52 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消