I am working on a symfony project using doctrine
So, I have 3 objects:
The project has actions with several groups, and activity has several categories
I am trying to get all the actions grouped by project categories.
What is the right way to do this?
I tried with QueryBuilder, but it seems that you cannot group with another object, only with a value (tell me if I am wrong)
$q = $repo->createQueryBuilder('a')
->leftJoin('a.project', 'p')
->leftJoin('a.categories', 'category')
->where('p.id = ?1')
->setParameter(1, $projectId)
->groupBy('category.id')
->getQuery();
return $q->getResult();
EDIT
I really need to show a list of categories with corresponding actions inside
-Category1
-Activity1
-Activity2
-Activity3
-Category2
-Activity3
-Activity4
-Category4
-Activity1
-Activity2
-Activity3
-Activity4
-Activity5
My way of doing this is good, and my code is wrong? Or am I mistaken everywhere?
Thank you very much for your time!