$having = 'distance <= 5000'
$merch_store_info = db('merch_store')
->alias('ms')
->join('merch_cate mc','ms.cateid = mc.id','left')
->join('merch_sign sn','ms.sign_id = sn.id','left')
->where($where)
->field("ms.id,name,ms.business_time,ms.business_time_start,ms.business_time_end,ms.head_img,ms.address,ms.sales_count,mc.title as cate_name,sn.title as sign_name,sn.color,ms.lng,ms.lat,(6378.138 * 2 * asin(sqrt(pow(sin((lat * pi() / 180 - ".$lat." * pi() / 180) / 2),2) + cos(lat * pi() / 180) * cos(".$lat." * pi() / 180) * pow(sin((lng * pi() / 180 - ".$lng." * pi() / 180) / 2),2))) * 1000) as distance")
->having($having)
->order($sort)
->page($page, $pagesize)
->select();
php 根据经纬度查询距离
最新推荐文章于 2023-06-05 14:30:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)