我正在尝试使用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