Doctrine DQL : Expected known function, got ‘acos’

I downloaded "Beberlei" package with composer.

Everything is correctly added in my project :

enter image description here

I changed the file config/"doctrine.yaml" by adding those functions :
enter image description here

I’m trying to use them like this :

  public function findCitiesInRange()
    {
        $lat = 49.3167;
        $lng = 2.55;
        return $this->createQueryBuilder('v')
            ->select('v')
            ->addSelect('(6371 * acos(cos(radians(:lat)) * cos(radians(v.latitude)) * cos(radians(v.longitude) - radians(:lng)) + sin(radians(:lat)) * sin(radians(v.latitude)))) AS distance')
            ->having('distance <= 50')
            ->setParameter('lat', $lat) 
            ->setParameter('lng', $lng) 
            ->getQuery()
            ->getResult()
        ;
    }

I get a "Syntax Error" :

enter image description here

Source: Symfony4 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *