]> 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:08 +0000 (19:39 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 4 Mar 2008 19:39:08 +0000 (19:39 +0000)
parameter value)

NEWS
ext/mssql/php_mssql.c

diff --git a/NEWS b/NEWS
index e8f50f270381a3014f3d929cb3d050d713eb6073..a2590d771872b25e1f039c8a516c636970ab3675 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Mar 2008, PHP 5.2.6
+- Fixed bug #44325 (mssql_bind not correctly bind empty strings as parameter  
+  value). (Ilia)
 - Fixed bug #44306 (Better detection of MIPS processors on Windows). (Ilia)
 - Fixed bug #44166 (Parameter handling flaw in PDO::getAvailableDrivers()).
   (Ilia)
index c91b98d7dd52a028cb7937ba9b43c285b6e733cf..7ad75912f27806dfe247a09b58c0c5f346ce6fc3 100644 (file)
@@ -2063,14 +2063,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 */