gpt4 book ai didi

php - 在 Laravel 应用程序中,mysql import 将时间戳 null 值转换为 0000-00-00 00 :00:00

转载 作者:行者123 更新时间:2023-11-29 20:06:15 25 4
gpt4 key购买 nike

在 Laravel 应用程序中,我有一个 MySQL 时间戳字段 deleted_at,它是为 softDeletes 创建的,默认值为 NULL。如果该值不为 NULL,Eloquent 将不会检索数据。当我导入 CSV 文件时,源文件中的 NULL 值变为 0000-00-00 00:00:00。

我读到Mysql import transforms timestamp null values to 0000-00-00 00:00:00和\N 对我不起作用。我有很多需要定期导入的表,所以我真的需要解决这个问题。请帮忙。

最佳答案

您需要在 MySQL 中禁用严格模式。特别是,模式名称是 STRICT_TRANS_TABLES 。打开 /etc/mysql/my.cnf (或 Windows 中的同一文件)找到并注释掉 STRICT_TRANS_TABLES

更多信息在这里:

http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict

关于php - 在 Laravel 应用程序中,mysql import 将时间戳 null 值转换为 0000-00-00 00 :00:00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40342778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com