回覆,
我有以下查询:
$property =
Property::select(
DB::raw("title, lat, lng, (
3959 * acos(
cos( radians(:lat) ) *
cos( radians( lat ) ) *
cos( radians( lng ) - radians(:lng) ) +
sin( radians(:lat) ) *
sin( radians( lat ) )
)
) AS distance", ["lat" => $lat, "lng" => $lng, "lat" => $lat])
)
->having("distance", "<", $radius)
->orderBy("distance")
->take(20)
->get();
Run Code Online (Sandbox Code Playgroud)
它不起作用:Invalid parameter number: mixed named and positional parameters.
有没有人知道一个技巧或解决方法(我显然可以编写完整的查询,但更喜欢使用流利的构建器).