我的代碼是 whereRaw("DAY(time) = ?", $day)->get();但是我的代碼現在不起作用...我不明白,因為whereRaw("DAY(time) = ?", 5)->get()是做工作。為什么沒有工作$day代碼?我得到使用時間Carbon::now()并得到一天$time->day;DAY(time) = ?", $day)->get() <不工作DAY(time) = ?", 8)->get() < 工作我不明白。$result = DB::table('show')->whereYear('time',$year)->whereMonth('time',$month)->where(function ($mQuery){$mQuery->whereRaw("DAY(time) = $day")->whereRaw("HOUR(time) >= ?", $hour)->orWhereRaw("DAY(time) > $day");})->get();對不起,我的英語不好。
1 回答

皈依舞
TA貢獻1851條經驗 獲得超3個贊
我解決了這個問題。
我沒有用這個
使用 ($day, $hour)
<< 所以,我的代碼沒有得到 $day, $hour ...
我的代碼 $day, $hour 為空。
更改我的代碼->
$result = DB::table('board_show')->whereYear('time',$year)->whereMonth('time',$month)->where(function ($mQuery) use ($day, $hour) {$mQuery->whereRaw("DAY(time) = ?", [$day])->whereRaw("HOUR(time) >= ?", [$hour])->orWhereRaw("DAY(time) > ?", [$day]);})->get();
- 1 回答
- 0 關注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消