samedi 26 janvier 2019

How to set null in updated_at` field?

I laravel 5.7 app I see that for some rows

field defined as :

updated_at TIMESTAMP NULL DEFAULT NULL,

has value 0000-00-00 00:00:00

I try to run next statement :

DB::table('clients')
  ->where('updated_at','0000-00-00 00:00:00')
  ->update([
      "updated_at" => null
  ]);

But got error :

: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'updated_at' at row 1 (SQL: update `clients` set `updated_at` =  whe
re `updated_at` = 0000-00-00 00:00:00)                 

Which is correct ?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire