]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #44325 (mssql_bind not correctly bind empty strings as
authorIlia Alshanetsky <iliaa@php.net>
Tue, 4 Mar 2008 19:39:33 +0000 (19:39 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 4 Mar 2008 19:39:33 +0000 (19:39 +0000)
parameter value)

ext/mssql/php_mssql.c

index 12f84b57e92fb8884fdabdc2c5a9bce8bf77d4fd..a80f84ca83eb59773ea6a75dfbfb43654fea40d7 100644 (file)
@@ -2056,14 +2056,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 */