note 31593 deleted from function.mssql-execute by didou

From: Date: Sun, 04 Feb 2007 06:05:15 +0000
Subject: note 31593 deleted from function.mssql-execute by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122800@lists.php.net to get a copy of this message
Note Submitter: arnarb at oddi dot is ---- The above comment is probably outdated by now. I've been using mssql_init, mssql_bind and mssql_execute with good results on my Linux box, both with MSSQL 7.0 and 2000. My webserver is running Apache 1.3.24 with PHP 4.3.2-RC1 (this also works in 4.3.1) linked against an out-of-the-box build of FreeTDS 0.61. However, it should be mentioned here that the latest release (4.3.2-RC1) contains some bugs in the mssql_bind code. For one thing, the size of the buffer is not set correctly so unpatched, php coredumps when binding types of fixed length (SQLINT* and such). When binding types of variable length, such as strings (SQLVARCHAR and SQLCHAR for example), the _current_ string length is used to choose the buffer size instead of using the optional parameter $maxlen. To make this clearer: if you have a stored procedure that simply sets one of its output parameters to "Fixed string", this happens: $stringvariable = ""; mssql_bind($statement, "@outputparam", $stringvariable, SQLVARCHAR); mssql_execute($statement); // $stringvariable now contains "" and $stringvariable = "xxxx"; mssql_bind($statement, "@outputparam", $stringvariable, SQLVARCHAR); mssql_execute($statement); // $stringvariable now contains "Fixe" so the quick ugly hack is to initialize $stringvariable to a string longer than the one you expect to be returned. The tedious but nicer hack is to find the line datalen=Z_STRLEN_PP(var); in the function PHP_FUNCTION(mssql_bind) in php_mssql.c (around line 1970) and change it to: datalen=maxlen; and recompile :o) (note that this fails though when maxlen isn't specified in the PHP script)

« previous php.notes (#122800) next »