From: Ilia Alshanetsky Date: Tue, 4 Mar 2008 19:38:38 +0000 (+0000) Subject: Fixed bug #44325 (mssql_bind not correctly bind empty strings as parameter X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~704 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e17aa0630e2f86fe83fd35cc6d19dd0d178a92e;p=php Fixed bug #44325 (mssql_bind not correctly bind empty strings as parameter value) --- diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index 7987046982..822bcf15ad 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -2067,14 +2067,19 @@ PHP_FUNCTION(mssql_bind) /* modify datalen and maxlen according to dbrpcparam documentation */ if ( (type==SQLVARCHAR) || (type==SQLCHAR) || (type==SQLTEXT) ) { /* variable-length type */ - if (is_null) { + if (is_null || Z_TYPE_PP(var) == IS_NULL) { maxlen=0; datalen=0; - } - else { + } else { convert_to_string_ex(var); - datalen=Z_STRLEN_PP(var); - value=(LPBYTE)Z_STRVAL_PP(var); + datalen = Z_STRLEN_PP(var); + value = (LPBYTE)Z_STRVAL_PP(var); + if (!datalen) { + datalen = 1; + if (maxlen == -1) { + maxlen = 1; + } + } } } else { /* fixed-length type */