Answer the question
In order to leave comments, you need to log in
Symfony + Doctrine how to display 5 latest records from database?
How to display the last 5 records from a mySQL database in Symfony + Doctrine?
The controller has this code that displays all the records at once:
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$posts = $em->getRepository('BlogBundle:Post')->findAll();
return $this->render('post/index.html.twig', array(
'posts' => $posts,
));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question