首页 > 解决方案 > 如何在 updated_at` 字段中设置 null?

问题描述

我在 laravel 5.7 应用程序中看到了一些行

字段定义为:

updated_atTIMESTAMP NULL DEFAULT NULL,

具有价值 0000-00-00 00:00:00

我尝试运行下一条语句:

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

但出现错误:

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

哪个是对的 ?

谢谢!

标签: laravel-5eloquent

解决方案


推荐阅读