Reputation: 13
I have a simple problem.
I have some users. I have some contacts. Single User
can have some Contacts. One Contact
may be owned by many Users
, a simple ManyToMany
relation:
User <-> user_contact <-> Contact
How can I build a query that will return something like all Contact
s not owned by a User
. Those contacts may be owned by another User
or not.
Upvotes: 1
Views: 2194
Reputation: 8046
The MEMBER OF
option will do the magic.
I think you're looking for something like this:
$em->createQuery("select c from Contract c where :userId NOT MEMBER OF c.Users")
->setParameter("groupId", <<YOUR_USER_ENTITY_OR_USER_ID>>)
->getResult();
Ofcourse I don't know your entities, but I think this will give you some idea.
Upvotes: 7