1--TEST-- 2References to result sets - mysqlnd (no copies but references) 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8require_once('connect.inc'); 9if (!$IS_MYSQLND) 10 die("skip Test for mysqlnd only"); 11?> 12--FILE-- 13<?php 14 require_once('connect.inc'); 15 require_once('table.inc'); 16 17 $references = array(); 18 19 if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || 20 !($res = mysqli_store_result($link))) 21 printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 22 23 $idx = 0; 24 while ($row = mysqli_fetch_assoc($res)) { 25 /* will overwrite itself */ 26 $references[$idx]['row_ref'] = &$row; 27 $references[$idx]['row_copy'] = $row; 28 $references[$idx]['id_ref'] = &$row['id']; 29 $references[$idx++]['id_copy'] = $row['id']; 30 } 31 32 debug_zval_dump($references); 33 mysqli_free_result($res); 34 35 if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || 36 !($res = mysqli_use_result($link))) 37 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 38 39 $rows = array(); 40 for ($i = 0; $i < 2; $i++) { 41 $rows[$i] = mysqli_fetch_assoc($res); 42 $references[$idx]['row_ref'] = &$rows[$i]; 43 $references[$idx]['row_copy'] = $rows[$i]; 44 $references[$idx]['id_ref'] = &$rows[$i]['id']; 45 $references[$idx]['id_copy'] = $rows[$i]['id']; 46 /* enforce separation */ 47 $references[$idx]['id_copy_mod']= $rows[$i]['id'] + 0; 48 } 49 mysqli_free_result($res); 50 51 debug_zval_dump($references); 52 print "done!"; 53?> 54--EXPECTF-- 55array(1) refcount(%d){ 56 [0]=> 57 array(4) refcount(%d){ 58 ["row_ref"]=> 59 reference refcount(2) { 60 NULL 61 } 62 ["row_copy"]=> 63 array(2) refcount(1){ 64 ["id"]=> 65 string(1) "1" interned 66 ["label"]=> 67 string(1) "a" interned 68 } 69 ["id_ref"]=> 70 reference refcount(1) { 71 string(1) "1" interned 72 } 73 ["id_copy"]=> 74 string(1) "1" interned 75 } 76} 77array(2) refcount(%d){ 78 [0]=> 79 array(4) refcount(%d){ 80 ["row_ref"]=> 81 reference refcount(2) { 82 NULL 83 } 84 ["row_copy"]=> 85 array(2) refcount(%d){ 86 ["id"]=> 87 string(1) "1" interned 88 ["label"]=> 89 string(1) "a" interned 90 } 91 ["id_ref"]=> 92 reference refcount(1) { 93 string(1) "1" interned 94 } 95 ["id_copy"]=> 96 string(1) "1" interned 97 } 98 [1]=> 99 array(5) refcount(%d){ 100 ["row_ref"]=> 101 reference refcount(2) { 102 array(2) refcount(1){ 103 ["id"]=> 104 reference refcount(2) { 105 string(1) "2" interned 106 } 107 ["label"]=> 108 string(1) "b" interned 109 } 110 } 111 ["row_copy"]=> 112 array(2) refcount(%d){ 113 ["id"]=> 114 string(1) "2" interned 115 ["label"]=> 116 string(1) "b" interned 117 } 118 ["id_ref"]=> 119 reference refcount(2) { 120 string(1) "2" interned 121 } 122 ["id_copy"]=> 123 string(1) "2" interned 124 ["id_copy_mod"]=> 125 int(2) 126 } 127} 128done! 129