1--TEST-- 2References to result sets - mysqlnd (no copies but references) 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 require_once 'table.inc'; 12 13 $references = array(); 14 15 if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || 16 !($res = mysqli_store_result($link))) 17 printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 18 19 $idx = 0; 20 while ($row = mysqli_fetch_assoc($res)) { 21 /* will overwrite itself */ 22 $references[$idx]['row_ref'] = &$row; 23 $references[$idx]['row_copy'] = $row; 24 $references[$idx]['id_ref'] = &$row['id']; 25 $references[$idx++]['id_copy'] = $row['id']; 26 } 27 28 debug_zval_dump($references); 29 mysqli_free_result($res); 30 31 if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || 32 !($res = mysqli_use_result($link))) 33 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 34 35 $rows = array(); 36 for ($i = 0; $i < 2; $i++) { 37 $rows[$i] = mysqli_fetch_assoc($res); 38 $references[$idx]['row_ref'] = &$rows[$i]; 39 $references[$idx]['row_copy'] = $rows[$i]; 40 $references[$idx]['id_ref'] = &$rows[$i]['id']; 41 $references[$idx]['id_copy'] = $rows[$i]['id']; 42 /* enforce separation */ 43 $references[$idx]['id_copy_mod']= $rows[$i]['id'] + 0; 44 } 45 mysqli_free_result($res); 46 47 debug_zval_dump($references); 48 print "done!"; 49?> 50--CLEAN-- 51<?php 52require_once "clean_table.inc"; 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