Doctrine - how to check if a collection contains an entity
问题 I have two entities User and Article with many-to-many relation as Article can have many authors. class User { /** @var string */ public $name; /** @var Collection<Article> */ public $articles; } class Article { /** @var string */ public $title; /** @var Collection<User> */ public $authors; } How I can find all Articles with specified (co)author using DQL? 回答1: Use MEMBER OF expression. Your DQL query could like like SELECT art FROM Article art WHERE :user MEMBER OF art.authors or using query