0
用户有一个角色。 角色拥有零个或多个用户。Doctrine2获得无关系的对象
我想找到没有用户的角色。
我需要此查询,而无需使用IN或NOT IN
我试图加入:
$qb = $this->createQueryBuilder('role');
$qb
->leftJoin('role.users', 'users')
->where('users IS NULL')
没有加入
$qb = $this->createQueryBuilder('role');
$qb
->where('role.users IS NULL')
与ID:
$qb = $this->createQueryBuilder('role');
$qb
->leftJoin('role.users', 'users')
->where('users.role != role')
你有其他想法吗?除了使用IN/NOT IN查询之外,我没有别的选择吗?
在此先感谢
我有错误有任何用户的角色:无效PathExpression。 StateFieldPathExpression或SingleValuedAssociationField预期。任何想法为什么? – goto
@goto更改计数为COUNT(users.id)' –
谢谢,但你知道如何避免8250查询完成的教条:O – goto