我的代码在下面
$meetings = Event::select(\DB::raw("*, " .
"( " .
"6371 * " .
"acos( " .
"cos( radians('%s') ) * " .
"cos( radians( lattitude ) ) * " .
"cos( " .
"radians( longitude ) - radians('%s')" .
") + " .
"sin( radians('%s') ) * " .
"sin( radians( lattitude ) ) " .
")" .
") AS distance"))
->having('distance', '<=', '%s')
->setBindings([ $lat, $lng, $lat,$radius ], 'select')
->paginate(4);
此代码的输出为
“具有子句”中的未知列“距离”(SQL:从具有
中“具有子句”中的未知列“距离”event_table
<= 100的distance
中选择count(*)作为集合)“,” exception“:” PDOException:SQLSTATE [ 42S22]:找不到列:1054
但是当我写出来没有这样的输出时
#attributes: array:19 [
"event_id" => 2
"event_name" => "Test Event"
"event_description" => "this is a test event"
"event_live_url" => "http://www.facebook.com/event/test-event"
"address" => "Mirpur, Dhaka, Bangladesh"
"lattitude" => 23.810301
"longitude" => 90.412498
"creator_id" => 6
"start_time" => "2017-08-29 15:12:23"
"end_time" => "2017-08-29 00:00:00"
"timezone" => null
"event_phone" => "8801705092993"
"event_email" => "rhythm.shahriar.bd@gmail.com"
"event_facebook_page" => "http://www.facebook.com/event/test-event"
"price" => 200.0
"active" => 1
"event_category_id" => 1
"create_at" => "2017-08-29 15:12:23"
"distance" => 10049.507140444
]
为什么我在编写具有以下内容的查询时找不到距离