QSqlServerDatabase.php DATETIME field problem and fix.

Login or register to post comments
5 replies [Last post]
Vex
Offline
Joined: 03/26/2009

I'm working on a project with QCubed 1.1.1 and MSSQL Server. It appears that the dateformat used by QSqlServerDatabase.php (ISO Format) is invalid on our installation of SQL Server. And the only two formats guaranteed to work are yyyymmdd hh:mm:ss and yyyy-mm-ddThh:mm:ss.

I noticed that dateformat has been added to the database configuration for use with the new MSSQL adaptor QSqlServer2005Database.php (Ticket #288). But this new configuration option isn't in use in the QSqlServerDatabase.php adaptor.

Modifying line 113 of the file QSqlServerDatabase.php to use $this->DateFormat instead of QDateTime::FormatIso enables the configuration option to work, and allows me to use the MSSQL server adaptor properly by specifying the datetime format within the configuration file.

akrohn's picture
Offline
Joined: 11/14/2008

Are you using a linux platform or SQL Server 2000? Otherwise you could use the QSqlServer2005 database adapter.

Or did you set "datetimeconvert = off" in the php.ini setting of the mssql extension?

Vex
Offline
Joined: 03/26/2009

I'm developing on Windows, but I don't have the SQLSRV extension installed, and so can't use the QSqlServer2005 adapter, and the production server for this project maybe Linux or Windows. So this simple fix allows the older QSqlServer adapter to be used without dateformat issues.

mssql.datetimeconvert is commented out in my dev php.ini so I think that means it's on.

akrohn's picture
Offline
Joined: 11/14/2008

Did you try "datetimeconvert=off" ?

Vex
Offline
Joined: 03/26/2009

No I didn't.

I just implemented the fix outlined in my first post, this works fine for me, and I think it should be included in the core qcubed code, as it allows for greater flexibility, and has no impact on existing code.

alex94040's picture
Offline
Joined: 11/06/2008

Vex - can you do us a favor and create a ticket in Trac, attaching a patch file, so that we can include your finding into the core? That'd really help the community.

Thank you!