0

这是找到具有特定条件的第一个练习的功能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,
    ));
}
4

1 回答 1

0

你的问题在这里:

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

你需要找到某事。

$nextExercise= $em->getRepository('PrezentariPrezentariBundle:Exercise')->findOneById($exercise)->getNext();
于 2012-09-21T12:52:39.463 回答