如何用空值更新列?
how to update column with null value?
当我用空值更新列时,它给我这样的错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column '00:00:00' in 'field list' (SQL: update attendances
set 00:00:00
= 12:11:45 where (studentid
= 4 and date
= 2018-07-09))
查询
DB::table('attendances')
->where(['studentid' => $singleData['id'], 'date' => $date])
->update([$data['out_am'] => $time]);
我的控制器
您正在使用一个值作为字段名称。它可能应该是这样的:
DB::table('attendances')
->where(['studentid' => $singleData['id'], 'date' => $date])
->update(['out_am' => $data['out_am']]);
当我用空值更新列时,它给我这样的错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column '00:00:00' in 'field list' (SQL: update
attendances
set00:00:00
= 12:11:45 where (studentid
= 4 anddate
= 2018-07-09))
查询
DB::table('attendances')
->where(['studentid' => $singleData['id'], 'date' => $date])
->update([$data['out_am'] => $time]);
我的控制器
您正在使用一个值作为字段名称。它可能应该是这样的:
DB::table('attendances')
->where(['studentid' => $singleData['id'], 'date' => $date])
->update(['out_am' => $data['out_am']]);