
I am training on Symvony and CREATEQUERYBUILDER, I was ordering by a field to display data
I want to display data ORDERED BY Quantity left in stock but I want them also "grouped by" package ID.
I don’t know how to group by but still display all the other products (like in my 2nd pic)
If I don’t GROUP BY, I get all the data but it doesn’t respect "GROUP BY" package ID and product from package 1 and package 2 are entangled.
What I do is:
public function findAllOrderByQuantity(): array
{
$qb = $this->createQueryBuilder('pack')
->orderBy( 'pack.quantity', 'ASC')
->groupBy('pack.packageId')
;
$query = $qb->getQuery();
return $query->execute();
}
Could you please help me on that one? Thanks
Source: Symfony Questions
Was this helpful?
0 / 0