查询酒店商店定位器的距离计算不工作

Query for Distance Calculation for hotel storelocator not working

这是我在模型中的查询

 $array = array('dealercity' => $citycheck, 'lat' => $lat, 'lng' => $lng, 'sometype' => $sometypeid, 'type' => $typeid);
     $this->db->select("*, (
  3959 * acos (
  cos ( radians($lat) )
  * cos( radians( lat ) )
  * cos( radians( lng ) - radians($lng) )
  + sin ( radians($lat) )
  * sin( radians( lat ) )
)) AS distance");   

     $this->db->from('tbl_dealer_list');
     $this->db->where($array);
     $this->db->having('distance < 25');                     
     $this->db->order_by('distance');   
     $this->db->limit(25, 0);
     $query = $this->db->get();

问题是查询没有显示任何错误。当我搜索特定位置时,会显示相同的确切位置。 20 英里内的附近地点无法使用。我正在使用 Codeigniter 和 Mysql。 有知道答案的请指出错误

当我 运行 查询时,计算出的距离显示为某个值,例如 0.00005899369716644287。我检查了超过这个值的距离仍然没有显示附近的位置,并且当数据库中存在一个以上的位置时显示位置。

    $return =array();

       $query= $this->db->query("select *, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM tbl_dealer_list WHERE dealertype =  '".$dealerid."'AND vehicletype =  '".$vehicleid."' HAVING distance < 20 ORDER BY distance");

      if ($query->num_rows() > 0)
        {
        return $query->result();//$query->result_array()

         }