Answer the question
In order to leave comments, you need to log in
How, using Symfony 2/3 + Doctrine, to get entities that do not have a Many-To-One relationship?
Good afternoon.
There are 2 entities: Region and User. One region can have multiple users, a user can only have one region.
How to get through QueryBuilder users who do not have a region set?
public function findUsersWithoutRegion()
{
$query = $this->createQueryBuilder('u')
->where('u.region = :region')
->setParameter('region', null)
->orderBy('u.title')
->getQuery();
return $query->getResult();
}
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