我想在我的自定义存储库类中计算距离。问题是 Doctrine 在处理 ACOS 函数时抛出异常:
[Syntax Error] line 0, col 70: Error: Expected known function, got 'ACOS'
这是查询:
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();
}
有什么问题?