//距离计算
$sqrt = 'SQRT(POW(SIN(('.$latitude.'*PI()/180-`latitude`*PI()/180)/2),2)+COS('.$latitude.'*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(('.$longitude.'*PI()/180-`longitude`*PI()/180)/2),2))';
//表前缀
$prefix = config('database.prefix');
//条件
$where = "'%".$key."%'" ;
//sql语句
$sql = "select * from (select * ,ROUND(6378.138*2*ASIN($sqrt)*1000) AS distance from " .$prefix ."store". " where store_name like ". $where ." or address like ". $where ." order by distance,id) as a ";
Db::query($sql);
php sql Tencent map to calculate the distance based on the latitude and longitude points
Guess you like
Origin blog.csdn.net/weixin_43637581/article/details/104905638
Recommended
Ranking