SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '' for column 'xxx' at row 1

mysql5.7 datetime 默认值为‘0000-00-00 00:00:00'值无法创建问题解决

mysql5.7报错this is incompatible with sql_mode=only_full_group_by

select @@sql_mode;

解决办法:

不要加STRICT_TRANS_TABLES

执行如下命令即可

set @@global.sql_mode ='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

后来我直接在添加和更新的时候,增加了日期赋值,一劳永逸,不用考虑mysql环境了就$Content->create_time = date("Y-m-d H:i:s", time());

$Content->update_time = date("Y-m-d H:i:s", time());

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐