laravel having: Column not found

后端 未结 2 790
夕颜
夕颜 2020-12-20 03:38

my following code is like this:

$places = DivePlace::selectRaw(\"*,(st_distance_sphere( POINT(\".$lon.\",\".$lat.\") ,  point(lon, lat))/1000) as distance\")         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-20 03:52

    ->where(DB::raw("(ST_Distance_Sphere(POINT(".$lon.",".$lat."), POINT(lon,lat))/1000)"), '<', 200)
    

    instead of ->havingRaw("(st_distance_sphere( POINT(?, ?) , point(lon, lat))/1000) < ?", [$lon, $lat, $radius])

提交回复
热议问题