Laravel的选择查询中“哪里”不起作用

时间:2019-05-06 13:10:42

标签: php laravel laravel-5

这是我的代码,显示所有具有地理位置的结果

$jobs = Job::select(
            DB::raw("*, status,
                          ( 6371 * acos( cos( radians(?) ) *
                            cos( radians( latitude ) )
                            * cos( radians( longitude ) - radians(?)
                            ) + sin( radians(?) ) *
                            sin( radians( latitude ) ) )
                          ) AS distance"))
            ->having("distance", "<", "?")
            ->setBindings([$service->latitude, $service->longitude, $service->latitude, 30])
            ->with(['user'])
            ->orderBy("id", "desc");

        $jobs = $jobs->simplePaginate(10);

但是上面的代码无法与下面的“ where”一起使用,并给我一个空数组

$jobs = Job::select(
            DB::raw("*, status,
                          ( 6371 * acos( cos( radians(?) ) *
                            cos( radians( latitude ) )
                            * cos( radians( longitude ) - radians(?)
                            ) + sin( radians(?) ) *
                            sin( radians( latitude ) ) )
                          ) AS distance"))
            ->having("distance", "<", "?")
            ->setBindings([$service->latitude, $service->longitude, $service->latitude, 30])
            ->with(['user'])
            ->where("status", 3)   // not working
            ->orderBy("id", "desc");

        $jobs = $jobs->simplePaginate(10);

0 个答案:

没有答案