의 평균 값을 가져, 내 Repositoru에 내가이 수행교리/심포니
public function getFotoSpecifica($idFoto) {
$q = $this->createQueryBuilder('f');
$q->leftJoin("f.foto_votata", 'v');
$q->where('f.id =:idFoto');
$q->andWhere('(f.foto_privata IS NULL OR f.foto_privata != 1)');
$q->andWhere('(f.foto_eliminata IS NULL OR f.foto_eliminata != 1)');
$q->expr()->avg('v.punteggio', true);
$q->setParameter('idFoto', $idFoto);
$dql = $q->getQuery();
$results = $dql->getArrayResult();
return $results;
}
을하지만 난 값의 평균을 찾을 수없는, 내가 내 모든 객체를 참조하십시오 .. .i 내 컨트롤러에서 createQuery를 사용하려고하지만 다음과 같은 많은 오류가 있습니다. Error : Invalid PathExpression. StateFieldPathExpression이어야합니다. 외래 키가 $의 사진라는 이름이 뭔가를 할 수있는 개체는 컨트롤러에서 ProfVotoFoto 이다의 변수 이름을 가정
SELECT profilo_id, proprietario_id, round(AVG(punteggio),2) as avg_rate, SUM(punteggio) as score, foto_id, count(*) as numero_votanti
FROM prof_voto_foto
WHERE foto_id = ?
은 내가 으로 시도 $ 쿼리 = $ 보하기> createQuery (' SELECT v.id, SNFotoBundle FROM v.profilo : Voti의 V WHERE v.foto = idFoto ') - > setParameter ('idFoto', intval ($ id_immagine)); profilo는 ManyToOne/@ORM \ JoinColumn (name = "profilo_id", referencedColumnName = "id")입니다. – Barno