Marc
Marc

Reputation: 53

how to update column with null value?

As i update column with null value, it gives me an error like this:

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))

query

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

my controller

[Image]

Upvotes: 4

Views: 3226

Answers (1)

Brian Lee
Brian Lee

Reputation: 18187

You are using a value as a field name. It should probably be something like this:

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

Upvotes: 3

Related Questions