Question

entity:

 class Pharmacie{    
      public $distance;

     public function getDistance() {
          // calculate distance here 
          return $distance; 
    }

}

and in controller:

 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));
}

error: [Semantical Error] line 0, col 65 near 'distance ASC': Error: Class Centrale\FrontBundle\Entity\Pharmacie has no field or association named distance

Was it helpful?

Solution

  • it's a bad practice to create query directly in your controller, you should create function in your repository
  • distance property should be protected or private not public
  • where is your mapping ???
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top