开发者

Doctrine can't insert DateTime into MSSQL 2005

I am using Doctrine 2.0 with php5.3 , being served from apache2 with a MSSQL\SQLEXPRESS 2005 backend.

My problem is that when I go to insert a record with a DateTime object, I get the error.

PDOException: SQLSTATE[22007]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting datetime from character string.

As part of troubleshooting, I have verified that the target column is in fact of the type datetime. And I have echoed the query using the EchoLogger which returns something like this

INSERT INTO proposal (proposaldate, ...)
   VALUES (?..) { [1]=> object(DateTime)#264 (3) { ["date"]=> string(19) "2010-11-20 22:15:12" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" }..}
开发者_如何转开发

The most disconcerting thing is that a similar class using the same packages executes flawlessly when inserting the datetime in the same manner.

Any help is greatly appreciated.


Sounds like a locale issue. To overcome, write your strings out in ISO 8601 format, ie. YYYYMMDD

2010/21/11
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜