Doctrine where condition on relation but still load all relations
I am encountering a problem with a relatively simple query:
$qb = $this->createQueryBuilder('uG');
$qb->innerJoin('uG.users', 'u')
->andWhere('u.username = :user')
->setParameter('user', $user->getUsername());
So I want to get all Usergroups for a specific user. But I also want to
show in my view, the number of users within this group:
{{ usergroup.users|length }}
But the problem is that due to the where and join I only selected the
current user. So even if there are several people in a group the number of
users is still 1 because I select only one.
How can I get the groups of one user but still select all users for those?
No comments:
Post a Comment