- 直接在控制器中创建查询是一种不好的做法,您应该在存储库中创建函数
- 远程财产应受到保护或私人而不是公共
- 你的映射在哪里???
Orderby计算PROPRITIE实体
-
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':错误:Class Centrale FrontBundle Entity entity Pharmacie没有字段或关联距离距离
解决方案
不隶属于 StackOverflow