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