我有一个带有 Doctrine 1 的应用程序,我通过 new Zend_Date->getIso()
为对象生成 update_datetime
字段.多年来它一直运行良好,但现在我有了一个新笔记本,Doctrine 尝试将 DATETIME
字段作为字符串插入 "2013-07-12T03:00:00+07:00"
而不是正常的 MySQL 日期时间格式 "2013-07-12 00:00:00"
这完全是奇怪的.
I have an app with Doctrine 1 and I generate update_datetime
fields for objects via new Zend_Date->getIso()
. It worked just fine for years, but now I got a new notebook and Doctrine tries to insert a DATETIME
fields as a string "2013-07-12T03:00:00+07:00"
instead of normal MySQL datetime format "2013-07-12 00:00:00"
which is totally weird.
完全相同的代码在另一台计算机上运行得很好.一切都几乎相同——两者都是 MySQL 5.6.12、PHP 5.3.15.知道我应该去哪里看吗?
The very same code runs just fine on another computer. Everything is nearly identical – MySQL 5.6.12, PHP 5.3.15 on both. Any idea where should I look?
致命错误:未捕获的异常 'Doctrine_Connection_Mysql_Exception' 带有消息 'SQLSTATE[22007]:无效的日期时间格式:1292 不正确的日期时间值:'2013-07-12T03:00:00+07:00' 列'nextrun''在第 1 行'在 library/Doctrine/Connection.php:1083
更新
好的,在 StackOverflow 社区的帮助下,我终于解决了.问题在于 sql_mode
变量中的 STRICT_TRANS_TABLES
.但是在 /etc/my.cnf
中更改它似乎还不够,所以我必须运行 mysql -uroot
并键入以下内容:
Ok with the help from StackOverflow community I finally solved it. The problem was with STRICT_TRANS_TABLES
in sql_mode
variable. But changing it in /etc/my.cnf
seemed not enough, so I had to run mysql -uroot
and type the following:
set sql_mode=NO_ENGINE_SUBSTITUTION;设置全局 sql_mode=NO_ENGINE_SUBSTITUTION;
从而删除STRICT_TRANS_TABLES
更新2如何永远摆脱 STRICT?如何摆脱 MySQL 中的 STRICT SQL 模式一个>
UPDATE2 How to get rid of STRICT forever? How to get rid of STRICT SQL mode in MySQL
如果存在,您可以尝试从 my.ini 中的 sql-mode 中删除 STRICT_TRANS_TABLES
.
If it exists, you can try removing STRICT_TRANS_TABLES
from sql-mode in your my.ini.
这可能会导致此错误,日期时间字符串值包含您尚未转换为 mysql 日期时间的格式.将此 my.ini 更改报告为以下位置的修复:
This can cause this error with a datetime string value containing the format you have not being converted to mysql datetime. This my.ini change was reported as a fix in:
这篇关于MYSQL 不正确的 DATETIME 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!