2012-06-14 21 views
7

Desidero calcolare la distanza nella mia classe di repository personalizzata. Il problema è che Doctrine genera un'eccezione durante l'elaborazione funzione ACOS:Doctrine Query Builder Impossibile trovare la funzione ACOS

[Syntax Error] line 0, col 70: Error: Expected known function, got 'ACOS' 

Ecco la domanda:

public function findLocation($latitude, $longitude) 
{ 
    $em = $this->getEntityManager(); 
    return $em->createQueryBuilder() 
        ->select('((ACOS(SIN('.$latitude.' * PI()/180) * SIN(p.latitude * PI()/180) + COS('.$latitude.' * PI()/180) * COS(p.latitude * PI()/180) * COS(('.$longitude.' – p.longitude) * PI()/180)) * 180/PI()) * 60 * 1.1515) AS distance') 
        ->from('StrictPlaceBundle:Poi', 'p') 
        ->add('orderBy', 's.distance ASC') 
        ->getQuery()->getResult();  
} 

Che cosa può essere sbagliato?

risposta

Problemi correlati