使用Doctrine查詢生成器,你可以從這樣一個項目的所有門票:
$project_id = ...
$repository = $this->getDoctrine()->getRepository('AcmeBundle:Ticket');
$query = $repository->createQueryBuilder('t')
->join('t.sprint', 's')
->join('s.milestone', 'm')
->join('m.project', 'p')
->where('p.id = :project_id')
->setParameter('project_id', $project_id)
->getQuery();
這是一個里程碑,所有門票多少可以檢索:
$milestone_id = ...
$repository = $this->getDoctrine()->getRepository('AcmeBundle:Ticket');
$query = $repository->createQueryBuilder('t')
->join('t.sprint', 's')
->join('s.milestone', 'm')
->where('m.id = :milestone_id')
->setParameter('milestone_id', $milestone_id)
->getQuery();