CK knows Wayne

MSSQL with PHP: smalldatetime

Published at by Christian Kruse, updated at
Filed under: mssql, php, smalldatetime, bug, crash

A few days ago I got a SIGSEGV when querying the MSSQL server with PHP. There was nothing special with the query, just a normal SELECT statement, even without WHERE limitations. After examining it a little bit I found out, that it depended on the columns I selected. When I left out some specific columns in the SELECT, everything was ok.

First I thought that it depends on the values of the columns, but I couldn't really figure out a systematic. So only one conclusion is left: it is the column type. PHP crashes when querying a column with the smalldatetime type. After some research I found, that it depends on the configuration parameter mssql.datetimeconvert. If it is turned on, PHP crashes. If it is turned off, everything works fine. So for now, all my PHP scripts working with MSSQL Server begin like this:

if(ini_get('mssql.datetimeconvert')) {
	echo "---------- WARNING! TURN OFF mssql.datetimeconvert! It causes PHP to crash on smalldatetime fields!\n";
	echo "We're turning it off now for this script, but you should do it globally!\n";
	ini_set('mssql.datetimeconvert',"off");
}

Hope that helps.

No comments, yet

Comment Feed: RSS / Atom

Your Comment

You can use MarkDown to format your comment: *Word* for italic, **Word** for bold, images will get removed.




Because of massive spam attacks you may only post if you can answer the following question: