我正在嘗試使用in_time
和out_time
在同一個表中更新daiy_attendance
表中的hours_worked
列。已存儲在表中的in_time
和out_time
。Laravel中的數據庫更新查詢?
所以我使用timediff
來獲得差異。當我在phpmyadmin
sql格式上嘗試時,查詢運行並正確執行,但是當我嘗試在程序中運行時,它不更新hours_worked
列。它不會給出任何錯誤。
$sql5 = "UPDATE daily_attendances SET hours_worked = TIMEDIFF(out_time,in_time) WHERE in_time != '' AND out_time != '' ";
$result2 = DB::statement(DB::raw($sql5));
不知道是否是相關的:你設置 'time_worked' 可填充? –
@JohnDoe它可以爲空 – colombo
@JohnDoe OP沒有使用模型,所以'$ fillable'屬性是不相關的。 – fubar