Laravel 如何用空值更新列?

Laravel 如何用空值更新列?,laravel,laravel-5.4,Laravel,Laravel 5.4,当我用空值更新列时,它会给我一个如下错误: DB::table('attendances') ->where(['studentid' => $singleData['id'], 'date' => $date]) ->update(['out_am' => $data['out_am']]); SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“00:00:00”(SQL:updateAttentationsset00:00

当我用空值更新列时,它会给我一个如下错误:

DB::table('attendances')
    ->where(['studentid' => $singleData['id'], 'date' => $date])
    ->update(['out_am' => $data['out_am']]);

SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“00:00:00”(SQL:update
Attentations
set
00:00
=12:11:45,其中(
studentid
=4和
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']]);

发布您的查询生成器code@MKhalidJunaid抱歉,我现在编辑了我的帖子$data['out_am']是我在foreach.SQLSTATE[42S22]中得到的:未找到列:1054“字段列表”中的未知列“00:00:00”(SQL:update
Attentications
set
00:00
=12:27:14,其中(
studentid
=4和
date
=2018-07-09))您是否仍在使用
->update([$data['out\u am']=>$time])?没有,先生。我尝试->更新([$time=>$data['out\u am']]);仍然会得到相同的错误,好的,同样地,你使用一个值作为列,你不能使用一个变量作为数组索引。如果您的列在表中被命名为
out\u am
,那么它必须是这样的:
->update(['out\u am'=>$data['out\u am']])
->update(['out\u am'=>$time])