]> granicus.if.org Git - php/commitdiff
Fix mysqli_stmt_attr_set in libmysql mode.
authorAndrey Hristov <andrey@php.net>
Fri, 25 Sep 2009 12:25:54 +0000 (12:25 +0000)
committerAndrey Hristov <andrey@php.net>
Fri, 25 Sep 2009 12:25:54 +0000 (12:25 +0000)
mysql_stmt_attr_set returns my_bool instead of int.
If it was int, then 0 is success and !0 is failure, but
for my_bool 0 (FALSE) is failure and !0 is success.

ext/mysqli/mysqli_api.c
ext/mysqli/tests/mysqli_stmt_attr_set.phpt

index ffed8ba32ccc94d5e141cb69fd9dfc7f45b1b10d..07bc303d725292257866cd343502e000d0663101 100644 (file)
@@ -2128,7 +2128,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
 
        mode = mode_in;
 #if !defined(MYSQLI_USE_MYSQLND)
-       if (mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+       if (FALSE == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
 #else
        if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
 #endif
index 1964fe82d0161de233457b817d1504f9cff6b265..312f9f0f389fcde1c4bb01ef54dcaff6f0c38612 100644 (file)
@@ -58,7 +58,7 @@ require_once('skipifconnectfailure.inc');
                do {
                        $invalid_attr = mt_rand(-1 * PHP_INT_MAX + 1, PHP_INT_MAX);
                } while (in_array($invalid_attr, $valid_attr));
-               if (true !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
+               if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
                        /* Although it may be desired to get false neither the MySQL Client Library nor mysqlnd are supposed to detect invalid codes */
                        printf("[006b] Expecting boolean/true for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
        }
@@ -265,4 +265,4 @@ require_once('skipifconnectfailure.inc');
        require_once("clean_table.inc");
 ?>
 --EXPECTF--
-done!
\ No newline at end of file
+done!