我在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