note 31593 added to function.mssql-execute

From: Date: Sun, 27 Apr 2003 13:13:48 +0000
Subject: note 31593 added to function.mssql-execute
Groups: php.notes 
Request: Send a blank email to php-notes+get-47168@lists.php.net to get a copy of this message
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) -- http://www.php.net/manual/en/function.mssql-execute.php http://master.php.net/manage/user-notes.php?action=edit+31593 http://master.php.net/manage/user-notes.php?action=delete+31593 http://master.php.net/manage/user-notes.php?action=reject+31593

« previous php.notes (#47168) next »