問(wèn)題描述
我有一個(gè)帶有 Doctrine 1 的應(yīng)用程序,我通過(guò) new Zend_Date->getIso()
為對(duì)象生成 update_datetime
字段.多年來(lái)它一直運(yùn)行良好,但現(xiàn)在我有了一個(gè)新筆記本,Doctrine 嘗試將 DATETIME
字段作為字符串插入 "2013-07-12T03:00:00+07:00"
而不是正常的 MySQL 日期時(shí)間格式 "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.
完全相同的代碼在另一臺(tái)計(jì)算機(jī)上運(yùn)行得很好.一切都幾乎相同——兩者都是 MySQL 5.6.12、PHP 5.3.15.知道我應(yīng)該去哪里看嗎?
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?
致命錯(cuò)誤:未捕獲的異常 'Doctrine_Connection_Mysql_Exception' 帶有消息 'SQLSTATE[22007]:無(wú)效的日期時(shí)間格式:1292 不正確的日期時(shí)間值:'2013-07-12T03:00:00+07:00' 列'nextrun''在第 1 行'在 library/Doctrine/Connection.php:1083
更新
好的,在 StackOverflow 社區(qū)的幫助下,我終于解決了.問(wèn)題在于 sql_mode
變量中的 STRICT_TRANS_TABLES
.但是在 /etc/my.cnf
中更改它似乎還不夠,所以我必須運(yùn)行 mysql -uroot
并鍵入以下內(nèi)容:
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;設(shè)置全局 sql_mode=NO_ENGINE_SUBSTITUTION;
從而刪除STRICT_TRANS_TABLES
更新2如何永遠(yuǎn)擺脫 STRICT?如何擺脫 MySQL 中的 STRICT SQL 模式一個(gè)>
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.
這可能會(huì)導(dǎo)致此錯(cuò)誤,日期時(shí)間字符串值包含您尚未轉(zhuǎn)換為 mysql 日期時(shí)間的格式.將此 my.ini 更改報(bào)告為以下位置的修復(fù):
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:
- PING 導(dǎo)致 500 內(nèi)部服務(wù)器錯(cuò)誤 - 日期時(shí)間值不正確(AuthPuppy 錯(cuò)誤 #907203)
- PING causes 500 Internal Server Error - Incorrect datetime value (AuthPuppy Bug #907203)
這篇關(guān)于MYSQL 不正確的 DATETIME 格式的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!