mysql版本要求,5.6或以上
$shop_lng = 22.271620;
$shop_lat = 113.546830;
$order = 'distance ASC';
$field = "id,round(st_distance (point (ar_shop.long, ar_shop.lat),point(".$long.",".$lat.") ) / 0.0111,2) AS distance";
$res = Db::name('shop')->field($field)->order($order)->having("distance<5")->select();
print_dump($res);die;注意,若point后不添加ar_shop.直接写poing((long,lat),.....则会报错。tp5.1