我希望使用QueryBuilder
:
$query = $qb
->select('u')
->from('AppBundle:School', 'u')
->where('u.superAdmin = :user')
->andWhere(
$qb->join('u.admins', 'admins')
->where('admins = :user'))
->setParameters(array(':user' => $userArray))
->getQuery();
有人可以告诉我,我的工作方式如何?
答案 0 :(得分:2)
在您的SchoolRepository.php中:
$query = $this->createQueryBuilder('u')
->where('u.superAdmin = :user')
->leftJoin('u.admins', 'a')
->andWhere('a = :user')
->setParameter('user', $userArray)
->getQuery()
;
$results = $query->getResult();