我正在構建一個簡單的任務計劃程序。這是來自文件TaskController.php的一個片段。我如何將這3個查詢(任務,未完成,已完成)組合起來使其工作?我應該使用DQL嗎?Symfony2結合三個查詢的原則
/**
* Lists all task entities.
*
* @Route("/", name="task_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$tasks = $em->getRepository('TaskBundle:Task')->findByUser($this->getUser()); // all tasks of a specific user
$notcompleted = $em->getRepository('TaskBundle:Task')->findByCompleted(false); //tasks that are not completed
$completed = $em->getRepository('TaskBundle:Task')->findByCompleted(true); // all completed tasks
return $this->render('task/index.html.twig', array(
'notcompleted' => $notcompleted,
'completed' => $completed,
'tasks' => $tasks,
));
}
我想顯示已登錄用戶的所有完成的任務和登錄用戶的那麼沒有完成任務。 – Blazej