The relationship between the three tables
a oneToMany b
b oneToMany c
Purpose: I want to find all a data without c data
Example: Police Officer Li (a) has three guns (b) each gun has bullets (c)
What I want to find is the policeman without bullets. Add the three guns of Police Wang, two of them have no bullets, but if one gun has bullets, do not select him. I want to find the policeman without any bullets.
So I wrote the following code
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder();
$qb->select('a', 'b')
->from('aaBundle:a', 'a')
->leftJoin('a.b', 'b')
->leftJoin('b.c', 'c')
->where('c.id is null');
$query = $qb->getQuery();
$result = $query->getArrayResult();
But they found Police Wang, the policeman with a bullet in his gun.
How to modify this code.
First look for the gun without bullets, then look for the ID of the gun (the policeman with bullets), then NOT IN