MYSQL错误的DATETIME格式 [英] MYSQL incorrect DATETIME format
问题描述
新的Zend_Date-> getIso()$ c $生成 update_datetime
C>。几年来,它工作得很好,但是现在我得到了一个新的笔记本,并且Doctrine尝试插入一个 DATETIME
字段作为一个字符串2013-07-12T03 :00:00 + 07:00
而不是正常的MySQL日期时间格式2013-07-12 00:00:00
奇怪的。
相同的代码在另一台电脑上运行正常。一切都几乎相同 - MySQL 5.6.12,PHP 5.3.15两者。任何想法应该在哪里?
致命错误:未捕获的异常'Doctrine_Connection_Mysql_Exception'与消息'SQLSTATE [22007]:无效的日期时间格式:1292不正确日期时间值:图书馆/ Doctrine / Connection.php:1083
$ b中的列1'列'nextrun'的2013-07-12T03:00:00 + 07:00
$ b 更新
在StackOverflow社区的帮助下,我终于解决了。问题出在 sql_mode
变量中的 STRICT_TRANS_TABLES
。但是在 /etc/my.cnf
中更改它似乎还不够,所以我必须运行 mysql -uroot
并键入以下:
set sql_mode = NO_ENGINE_SUBSTITUTION;设置全局sql_mode = NO_ENGINE_SUBSTITUTION;
因此删除 STRICT_TRANS_TABLES
更新2
如何摆脱STRICT永远? 如何摆脱MySQL中的STRICT SQL模式
解决方案如果存在,您可以尝试从 STRICT_TRANS_TABLES
您的my.ini中的sql-mode。
这可能会导致此错误,其中包含未转换为mysql datetime的格式的datetime字符串值。这个my.ini更改已报告为:
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.
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?
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2013-07-12T03:00:00+07:00' for column 'nextrun' at row 1' in library/Doctrine/Connection.php:1083
UPDATE
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; set global sql_mode=NO_ENGINE_SUBSTITUTION;
Thus removing STRICT_TRANS_TABLES
UPDATE2
How to get rid of STRICT forever? How to get rid of STRICT SQL mode in MySQL
解决方案 If it exists, you can try removing STRICT_TRANS_TABLES
from sql-mode in your 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格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!