I have this error :
"Notice: Undefined offset: 0 in C:\wamp\www\Videotheque\vendor\doctrine\lib\Doctrine\ORM\QueryBuilder.php line 240"
I am creating a video collection online. There are 2 entities : Film and Genre. In my GenRerepositorymethod, I tried to redefine the function findAll() to the number of films associated to a genre.
This is the function :
public function myFindAll()
{
$genres = $this->_em->createQueryBuilder('g')
// leftJoin because I need all the genre
->leftJoin('g.films', 'f')
->addSelect('COUNT(f)')
->groupBy('g')
->getQuery()
->getArrayResult();
// $genres contains all the genres and the associated movies
return ($genres);
}