我在Laravel雄辯中遇到了一個問題,當我運行查詢並且生成的查詢似乎不是我期望的結果時,我得不到結果。高級Where子句在Laravel
這是在控制器代碼:
$lastUpdate = Input::get('last_update');
$userId = Auth::user()->id;
$eventIds = EventVendor::where('user_id', $userId)
->where('is_active', 1)->get()->lists('event_id');
$events = EventDetails::whereIn('id', $eventIds)
->where(function($query) use ($lastUpdate) {
$query->where('created_at', $lastUpdate);
$query->orWhere('updated_at', $lastUpdate);
})
->where('is_active', 1)
->with("details_sub")
->with("extras")
->with("chargesDiscounts")
->toSql();
這是生成的查詢:
select * from `mtgh_event_details`
where `mtgh_event_details`.`deleted_at` is null
and 0 = 1
and (`created_at` = ? or `updated_at` = ?)
and `is_active` = ?
除了這是不應該在那裏我看不到0 = 1
完整的查詢要麼。
「0 = 1」是否實際顯示在您的查詢中,或者是您爲該問題更改了哪些內容? – patricus
它顯示在我的查詢中。 – user3718908