I am a beginner in symfony 4, and I wanted to count the recording of an object, but it does not work. this is my code
// Function count() in my repository class
public function count()
{
return $this->createQueryBuilder('d')
->select('count(d.codeMarche) as count')
->getQuery()
->getSingleScalarResult();
}
// in my controller class, i called my function count()
/**
* @Route("/", name="home")
*/
public function hom(MarcheDAORepository $repo){
$count = $repo->count();
return $this->render('index/home.html.twig', ['nbrDAO'=>$count]);
}
i need your help!!