0
내가 엔티티 1이 : Upload
, 그것은 내가 업로드에 대한 사용자 정의 respository이 comments
Symfony2/Doctrine2 : 다른 엔티티 (ManytoOne)의있는 OrderBy 수
에 oneToMany
관계를 가지고 있으며, 내가 가장 주석 업로드를 찾으려면 .
[Semantical Error] line 0, col 55 near 'comments DES': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.
500 Internal Server Error - QueryException
은 내가이 문제를 해결하는 방법 또는이 될 것입니다 무슨, 의견의 수에 의하여 주문을 수용 할 않는 것 같다
그래서 오류를
/**
* @param $sortBy String
* @param $limit Int
*/
public function getWeekTopUploads($sortBy,$limit){
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->add('select', 'u')
->add('from', 'TrackerMembersBundle:Upload u')
// ->where('u.created')
->orderBy('u.comments', 'DESC')
->setMaxResults($limit);
$query = $qb->getQuery();
$result = $query->getResult();
return $result;
}
를 얻을 내가 할 때 쿼리 빌더에 대한 적절한 다시 쓰기?
.. .. 변수 $에 주석을 추가 하시겠습니까? – Confidence
나는 내 대답을 편집했다. 먼저 Upload와 관련된 모든 사용자 정의 쿼리를 저장하는 UploadRepository에 함수를 넣어야합니다. 위의 코드를 시도해보십시오. 오타를 만들었지 만 정신이 여기에 있습니다. – guillaumepotier