質問

実在物:

 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」:エラー:クラスCentrale frontbundle entity Pharmacieには距離という名前のフィールドまたは関連付けがありません

役に立ちましたか?

解決

  • コントローラーで直接クエリを作成するのは悪い習慣です。リポジトリに関数を作成する必要があります
  • 距離プロパティは、公開されていない、または私的である必要があります
  • あなたのマッピングはどこにありますか?
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top