У меня есть таблица "note" с "matiere_id", у меня есть таблица "matiere" с именем поля.Я хотел бы отобразить среднее количество заметок по темам.Я не знаю, как написать мой запрос с symfony4.
в моем хранилище:
public function findTest($id)
{
return $this -> createQueryBuilder ( 'n' )
->select("avg(n.note) as note_avg")
->where('n.idMatiere = :idMatiere')
->groupBy('n.idMatiere')
->setParameter('idMatiere', $id)
->getQuery();
}
в моем контроллере:
$repo = $this->getDoctrine()->getRepository(Notation::class);
$tabMatieres = $this->getDoctrine()
->getRepository(Matiere::class)
->findBy([], ['nom' => 'ASC']);
$tests = $repo->findTest ();