我想根据距离公式对列表进行排序。以下查询工作正常,但不知道如何使用cakephp实现这一点。
"SELECT *, ( 3959 * acos( cos( radians($locality_latitude) ) * cos( radians(locality_latitude) ) * cos( radians( locality_longitude ) - radians($locality_longitude) ) + sin( radians($locality_latitude) ) * sin( radians( locality_latitude ) ) ) ) AS distance FROM officers Officer JOIN localities Locality JOIN cities City ON locality.id = officer.locality_id AND city.id = officer.city_id WHERE officer.city_id =$city_id $des ORDER BY instant distance"
答案 0 :(得分:0)