Purpose: to filter. On the one hand, where we have some known summable conditions that we want to filter out (for example, the score of the original parts in a bunch) on many sides of the O2M relationship, where they want to limit one side along with some other selection criteria.
Then we add several conditions for the LEFT_JOIN operation: Condition No. 1 - identifier bundle.id == original_part.bundle. Condition No. 2 - Original_part. PartStatusType == 3 (some solid value).
Then we filter to COUNT (op)> = 1, which gives our more limited answer, which works great with pagination.
$qb->leftJoin(OriginalPart::class, 'op', Expr\Join::WITH, $qb->expr()->andX( $qb->expr()->eq('op.bundle', 'row.id'), $qb->expr()->eq('op.partStatusType', 3))); $qb->groupBy('row.id'); $qb->having($qb->expr()->gte('COUNT(op)', 1));
row is an alias for One (bundle object).
source share