如何在不覆盖它的情况下传输$ exercise参数?

时间:2012-09-21 11:26:01

标签: php symfony

以下是使用特定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,
    ));
}

1 个答案:

答案 0 :(得分:0)

你的问题在这里:

$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->getNext($exercise);

你需要找到......

$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneById($exercise)->getNext();