Symfony OrderBy计算属性实体
实体:Symfony OrderBy计算属性实体,symfony,doctrine-orm,entitymanager,Symfony,Doctrine Orm,Entitymanager,实体: class Pharmacie{ public $distance; public function getDistance() { // calculate distance here return $distance; } } 在控制器中: public function listePharmsGeoAction() { $em = $this->getDoctrine()-&g
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行,第65列“距离ASC”附近:错误:Class Centrale\FrontBundle\Entity\Pharmacie没有名为“距离”的字段或关联
您的药房实体中没有距离属性。。。问题是什么?假设你的回答是bat距离没有表列到映射是用地址和ip filedOk计算的,所以这是正常的,你不能按不存在的列排序。我如何按计算适当性排序?