我想构建一个查询,以便我能够选择特定职业指导者所照顾的所有人。任何数量的职业指导者都可以照顾一个人。我正在考虑这种方式的查询,但我不能理解它,因为我是symfony的新手。
Select all persons where EngagedPersons.Persons id=1 and EngagedPersons.careerguides email = "email".
以下是我尝试的表结构
|persons | |engagedpersons| |careerguide|
|id | |id | |id |
|name | |uniqucode | |name |
|personfk | |specialty |
|careerguidefk |
|guidesemail |
请帮忙!
答案 0 :(得分:1)
正如chat中所述:
$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository("PalmyraApiBundle:Registration");
$queryBuilder = $repository->createQueryBuilder('registration');
$queryBuilder
->join('registration.engagedsuper', 'engagedActivities')
->join('engagedActivities.engagedweakgiver', 'caregiver')
->where('registration.id = :id')
->andWhere('caregiver.email = :email')
->setParameter('id', $id)
->setParameter('email', $email);