- 컨트롤러에서 직접 쿼리를 작성하는 것은 나쁜 관행입니다. 저장소에서 기능을 작성해야합니다.
- 거리 속성은 공개되지 않거나 개인이어야합니다
- 당신의지도는 어디에 있습니까 ???
Orderby는 독점 엔터티를 계산합니다
-
25-08-2022 - |
문제
실재:
class Pharmacie{
public $distance;
public function getDistance() {
// calculate distance here
return $distance;
}
}
그리고 컨트롤러에서 :
public function listePharmsGeoAction()
{
$em = $this->getDoctrine()->getEntityManager();
$pharmas = $em->getRepository('CentraleFrontBundle:Pharmacie')
->createQueryBuilder('o')
->orderBy('o.distance','ASC')
->getQuery()
->getResult();
return $this->render('CentraleFrontBundle:SiteFront:listePharms.html.twig', array(
'pharmas' => $pharmas));
}
오류 : [의미 적 오류] 라인 0, Col 65 근처의 '거리 ASC': 오류 : 클래스 센트 레일 FrontBundle Entity Pharmacie는 필드 또는 연관성이 없습니다.
해결책
제휴하지 않습니다 StackOverflow