我有这个原始查询,它在mysql中起作用,但在laravel 5.7中不起作用
$lat = '25.2645684753';
$long = '55.3381347656';
$lat
和$long
是请求输入。
$distance = DB::table('company')
->select(DB::raw('ROUND(111.045* haversine(latitude,longitude,'.$lat.', '.$long.'),2) AS distance_in_km'))
->orderBy('distance_in_km', 'ASC')
->get();
结果显示空[]
我使用-> tosql()检查了查询,并在mysql中运行它而没有任何错误并显示了结果。
SELECT ROUND(111.045* haversine(latitude,longitude,25.2645684753, 55.3381347656),2) AS distance_in_km FROM `company` ORDER BY `distance_in_km` ASC