2015-05-18 34 views

回答

2

使用MEMBER OF可能是您正在寻找的那个。应该是行中的东西:

$entityManager->createQueryBuilder() 
    ->select('u') 
    ->from('AppBundle:User', 'u') 
    ->where(':targetGroup NOT MEMBER OF u.groups') 
    ->setParameter('targetGroup', $group) 
    ->getQuery() 
    ->getResult(); 

这将需要当然事先做额外的查询。

// Find and get instance of the group any way you like. 
$group = $entityManager->find('AppBundle:Group', 8); 

更多阅读上的查询选择 - Here

查询可能需要一些调整,但它应该是一个良好的开端为您服务。如果您有任何问题,请不要犹豫。

相关问题