]> granicus.if.org Git - php/commitdiff
Finish refactoring of MySQLi
authorXinchen Hui <laruence@php.net>
Sun, 11 May 2014 11:37:48 +0000 (19:37 +0800)
committerXinchen Hui <laruence@php.net>
Sun, 11 May 2014 11:37:48 +0000 (19:37 +0800)
a few tests failed due to knew issue, I will disscuss with dmitry later

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

index 59d03e65798bf8d6731b157a75956a378580845b..6c38cfff44c621d8f571d04d6cdcfbd09cfcee55 100644 (file)
@@ -866,24 +866,6 @@ PHP_FUNCTION(mysqli_error)
 }
 /* }}} */
 
-#if 0
-#ifndef MYSQLI_USE_MYSQLND
-/* {{{ php_mysqli_stmt_copy_it */
-static void
-php_mysqli_stmt_copy_it(zval *copies, zval *original, uint param_count, uint current)
-{
-       if (!*copies) {
-               *copies = ecalloc(param_count, sizeof(zval *));
-       }
-       MAKE_STD_ZVAL((*copies)[current]);
-       *(*copies)[current] = *original;
-       Z_SET_REFCOUNT_P((*copies)[current], 1);
-       zval_copy_ctor((*copies)[current]);
-}
-/* }}} */
-#endif
-#endif
-
 /* {{{ proto bool mysqli_stmt_execute(object stmt)
    Execute a prepared statement */
 PHP_FUNCTION(mysqli_stmt_execute)
@@ -900,6 +882,22 @@ PHP_FUNCTION(mysqli_stmt_execute)
        MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
 
 #ifndef MYSQLI_USE_MYSQLND
+       if (stmt->param.var_cnt) {
+               int j;
+               for (i = 0; i < stmt->param.var_cnt; i++) {
+                       if (!Z_ISREF(stmt->param.vars[i])) {
+                               continue;
+                       }
+                       for (j = i + 1; j < stmt->param.var_cnt; j++) {
+                               /* Oops, someone binding the same variable - clone */
+                               if (Z_TYPE(stmt->param.vars[j]) == Z_TYPE(stmt->param.vars[i]) &&
+                                               Z_REFVAL(stmt->param.vars[j]) == Z_REFVAL(stmt->param.vars[i])) {
+                                       SEPARATE_ZVAL(&stmt->param.vars[j]);
+                                       break;
+                               }
+                       }
+               }
+       }
        for (i = 0; i < stmt->param.var_cnt; i++) {
                if (!Z_ISUNDEF(stmt->param.vars[i])) {
                        zval *param;
index b6bce0d9819ddf5d616b5575dcc6d4826959d689..9b5d476ac45d87a318fa48ef3fd2c2622e231db3 100644 (file)
@@ -85,61 +85,61 @@ array(7) refcount(2){
   [0]=>
   array(2) refcount(1){
     [%u|b%"id"]=>
-    long(1) refcount(1)
+    long(1)
     [%u|b%"label"]=>
     %unicode|string%(1) "a" refcount(1)
   }
   [1]=>
   array(2) refcount(1){
     [%u|b%"id"]=>
-    long(2) refcount(1)
+    long(2)
     [%u|b%"label"]=>
     %unicode|string%(1) "b" refcount(1)
   }
   [2]=>
   array(2) refcount(1){
     [%u|b%"id"]=>
-    long(1) refcount(1)
+    long(1)
     [%u|b%"label"]=>
     %unicode|string%(1) "a" refcount(1)
   }
   [3]=>
   array(2) refcount(1){
     [%u|b%"id"]=>
-    long(2) refcount(1)
+    long(2)
     [%u|b%"label"]=>
     %unicode|string%(1) "b" refcount(1)
   }
   [4]=>
   array(3) refcount(1){
     [%u|b%"id"]=>
-    &long(3) refcount(2)
+    &long(3)
     [%u|b%"label"]=>
     %unicode|string%(1) "a" refcount(1)
     [%u|b%"id2"]=>
-    &long(3) refcount(2)
+    &long(3)
   }
   [5]=>
   array(3) refcount(1){
     [%u|b%"id"]=>
-    &long(4) refcount(2)
+    &long(4)
     [%u|b%"label"]=>
     %unicode|string%(1) "b" refcount(1)
     [%u|b%"id2"]=>
-    &long(4) refcount(2)
+    &long(4)
   }
   [6]=>
-  &object(mysqli_result)#2 (5) refcount(2){
+  &object(mysqli_result)#%d (5) refcount(%d){
     [%u|b%"current_field"]=>
-    NULL refcount(1)
+    NULL
     [%u|b%"field_count"]=>
-    NULL refcount(1)
+    NULL
     [%u|b%"lengths"]=>
-    NULL refcount(1)
+    NULL
     [%u|b%"num_rows"]=>
-    NULL refcount(1)
+    NULL
     [%u|b%"type"]=>
-    NULL refcount(1)
+    NULL
   }
 }
 array(1) refcount(2){
@@ -151,4 +151,4 @@ array(1) refcount(2){
     %unicode|string%(1) "a" refcount(1)
   }
 }
-done!
\ No newline at end of file
+done!