以下是使用特定lessonid
public function exerciseAction($lessonid, $exercise)
{
$em = $this->getDoctrine()->getEntityManager();
$exercise = $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneByLesson($lessonid);
return $this->render('PrezentariPrezentariBundle:Page:exercise.html.twig', array(
'exercise' => $exercise,
'lessonid' => $lessonid,
));
}
在这里,我尝试逐个练习一个函数
public function exercisePagerAction($exercise)
{
$em = $this->getDoctrine()->getEntityManager();
$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->getNext($exercise);
return $this->render('PrezentariPrezentariBundle:Page:exercise.html.twig', array(
'exercise' => $nextExercise,
));
}
答案 0 :(得分:0)
你的问题在这里:
$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->getNext($exercise);
你需要找到......
$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneById($exercise)->getNext();