Answer the question
In order to leave comments, you need to log in
How to form query in symfony doctrine with ManyToMany field?
Hello!
There is an entity Chat
, it has a profile field of the ManyToMany type associated with the Profile entity
. You need to find a Chat in which there are necessarily several Profiles.
It is necessary that all transmitted be in this Chat.
I try like this, but it turns out that it checks one of the matches, not all.
public function findByTwoUsers(array $profiles)
{
return $this->createQueryBuilder('c')
->andWhere(':users MEMBER OF c.profile')
->setParameter('users', $profiles)
->getQuery()->getOneOrNullResult();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question