In my application there is a Case
entity that has a collection of Operator
entities.
When I execute this request :
$this->createQueryBuilder('c')
->leftJoin('c.operators', 'od') // d -> one-to-many -> operator
->setMaxResults(100)
->getQuery()
->getResult()
;
I get only 71 result (suppose that are Cases
without any Operator
).
Hydrating to array works well when there is no selection:
$this->createQueryBuilder('c')
->select('c, od') // notice select here which yields to 71 results (without it I get 100 results)
->leftJoin('c.operators', 'od')
->setMaxResults(100)
->getQuery()
->getArrayResult()
;
The things get really confusing as the real SQL obtained with ->getSQL()
returns 100 results in both cases.
Anyone can help ?
UPDATE
Actually I have precicely 100 results in the result set. These results are Cases
combined with Operators
. When Dossier
in the result set has multiple Operators
when this Dossier
enters multiple times to the result set. Doctrine automatically shrinks this result set of 100 lines to the array of 71 unique Cases
.