0
나는CreateQuery 교리 심포니 2 StateFieldPathExpression
다음public function getFoo($profilo_id){
$em = $this->getEntityManager();
$query = $em->createQuery('
SELECT l.id as like_id, l.spotted_id as spotted_id,count(l.spotted_id) as numero_likes
FROM SNLikeBundle:LikeSpotted l
LEFT JOIN SNFotoBundle:Foto f
WITH f.id = l.spotted_id
LEFT JOIN SNProfiloBundle:Profilo p
WITH f.profilo_id = p.id
WHERE p.id = :profilo_id
GROUP BY l.spotted_id
ORDER BY numero_likes DESC
')->setFirstResults(0)
->setMaxResults(10)
->setParameter('profilo_id', $profilo_id);
$results = $query->getResult();
return $results;
}
내가 가진이 오류
[Semantical Error] line 0, col 36 near 'spotted_id as': Error: Class SN\LikeBundle\Entity\LikeSpotted has no field or association named spotted_id
내가 변경을 선택 교리에서이 작업을 수행하려고 MySQL의
SELECT l.id as like_id, l.spotted_id as spotted_id,count(l.spotted_id) as numero_likes
FROM sn_like_spotted l
LEFT JOIN prof_foto f
ON f.id = l.spotted_id
LEFT JOIN sn_profilo p
ON f.profilo_id = p.id
WHERE p.id = 3
GROUP BY l.spotted_id
ORDER BY numero_likes DESC LIMIT 0,10
이 쿼리를 입력 :
내가 IDENTITYSELECT IDENTITY l.id as like_id, l.spotted as spotted_id,count(l.spotted) as numero_likes
으로 시도하지만 난 (자세한 내가 QueryBuilder도 만들려고이 오류를
[Syntax Error] line 0, col 26: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '.'
을 가지고 그런
[Semantical Error] line 0, col 36 near 'spotted as spotted_id,count(l.spotted)': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
:
나는이 오류가 기준, 동일한 결과)
,746,684,내 오류는 내가 해결 CreateBuilder 경우에 대한 문제가
$q->orderBy($q->expr()->count('l.spotted'), 'desc');