1--TEST-- 2mysqli_stmt_result_metadata 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 /*** test mysqli_connect 127.0.0.1 ***/ 14 $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); 15 16 mysqli_select_db($link, $db); 17 18 mysqli_query($link, "DROP TABLE IF EXISTS test_affected"); 19 mysqli_query($link, "CREATE TABLE test_affected (foo int, bar varchar(10) character set latin1) ENGINE=" . $engine); 20 21 mysqli_query($link, "INSERT INTO test_affected VALUES (1, 'Zak'),(2, 'Greant')"); 22 23 $stmt = mysqli_prepare($link, "SELECT * FROM test_affected"); 24 mysqli_stmt_execute($stmt); 25 $result = mysqli_stmt_result_metadata($stmt); 26 27 echo "\n=== fetch_fields ===\n"; 28 var_dump(mysqli_fetch_fields($result)); 29 30 echo "\n=== fetch_field_direct ===\n"; 31 var_dump(mysqli_fetch_field_direct($result, 0)); 32 var_dump(mysqli_fetch_field_direct($result, 1)); 33 34 echo "\n=== fetch_field ===\n"; 35 while ($field = mysqli_fetch_field($result)) { 36 var_dump($field); 37 } 38 39 print_r(mysqli_fetch_lengths($result)); 40 41 mysqli_free_result($result); 42 43 44 mysqli_stmt_close($stmt); 45 mysqli_query($link, "DROP TABLE IF EXISTS test_affected"); 46 mysqli_close($link); 47 print "done!"; 48?> 49--CLEAN-- 50<?php 51require_once("connect.inc"); 52if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 53 printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 54 55if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected")) 56 printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 57 58mysqli_close($link); 59?> 60--EXPECTF-- 61=== fetch_fields === 62array(2) { 63 [0]=> 64 object(stdClass)#5 (13) { 65 ["name"]=> 66 string(3) "foo" 67 ["orgname"]=> 68 string(3) "foo" 69 ["table"]=> 70 string(13) "test_affected" 71 ["orgtable"]=> 72 string(13) "test_affected" 73 ["def"]=> 74 string(0) "" 75 ["db"]=> 76 string(%d) "%s" 77 ["catalog"]=> 78 string(%d) "%s" 79 ["max_length"]=> 80 int(0) 81 ["length"]=> 82 int(%d) 83 ["charsetnr"]=> 84 int(%d) 85 ["flags"]=> 86 int(32768) 87 ["type"]=> 88 int(3) 89 ["decimals"]=> 90 int(0) 91 } 92 [1]=> 93 object(stdClass)#6 (13) { 94 ["name"]=> 95 string(3) "bar" 96 ["orgname"]=> 97 string(3) "bar" 98 ["table"]=> 99 string(13) "test_affected" 100 ["orgtable"]=> 101 string(13) "test_affected" 102 ["def"]=> 103 string(0) "" 104 ["db"]=> 105 string(%d) "%s" 106 ["catalog"]=> 107 string(%d) "%s" 108 ["max_length"]=> 109 int(0) 110 ["length"]=> 111 int(%d) 112 ["charsetnr"]=> 113 int(%d) 114 ["flags"]=> 115 int(0) 116 ["type"]=> 117 int(253) 118 ["decimals"]=> 119 int(0) 120 } 121} 122 123=== fetch_field_direct === 124object(stdClass)#6 (13) { 125 ["name"]=> 126 string(3) "foo" 127 ["orgname"]=> 128 string(3) "foo" 129 ["table"]=> 130 string(13) "test_affected" 131 ["orgtable"]=> 132 string(13) "test_affected" 133 ["def"]=> 134 string(0) "" 135 ["db"]=> 136 string(%d) "%s" 137 ["catalog"]=> 138 string(%d) "%s" 139 ["max_length"]=> 140 int(0) 141 ["length"]=> 142 int(%d) 143 ["charsetnr"]=> 144 int(%d) 145 ["flags"]=> 146 int(32768) 147 ["type"]=> 148 int(3) 149 ["decimals"]=> 150 int(0) 151} 152object(stdClass)#6 (13) { 153 ["name"]=> 154 string(3) "bar" 155 ["orgname"]=> 156 string(3) "bar" 157 ["table"]=> 158 string(13) "test_affected" 159 ["orgtable"]=> 160 string(13) "test_affected" 161 ["def"]=> 162 string(0) "" 163 ["db"]=> 164 string(%d) "%s" 165 ["catalog"]=> 166 string(%d) "%s" 167 ["max_length"]=> 168 int(0) 169 ["length"]=> 170 int(%d) 171 ["charsetnr"]=> 172 int(%d) 173 ["flags"]=> 174 int(0) 175 ["type"]=> 176 int(253) 177 ["decimals"]=> 178 int(0) 179} 180 181=== fetch_field === 182object(stdClass)#6 (13) { 183 ["name"]=> 184 string(3) "foo" 185 ["orgname"]=> 186 string(3) "foo" 187 ["table"]=> 188 string(13) "test_affected" 189 ["orgtable"]=> 190 string(13) "test_affected" 191 ["def"]=> 192 string(0) "" 193 ["db"]=> 194 string(%d) "%s" 195 ["catalog"]=> 196 string(%d) "%s" 197 ["max_length"]=> 198 int(0) 199 ["length"]=> 200 int(%d) 201 ["charsetnr"]=> 202 int(%d) 203 ["flags"]=> 204 int(32768) 205 ["type"]=> 206 int(3) 207 ["decimals"]=> 208 int(0) 209} 210object(stdClass)#5 (13) { 211 ["name"]=> 212 string(3) "bar" 213 ["orgname"]=> 214 string(3) "bar" 215 ["table"]=> 216 string(13) "test_affected" 217 ["orgtable"]=> 218 string(13) "test_affected" 219 ["def"]=> 220 string(0) "" 221 ["db"]=> 222 string(%d) "%s" 223 ["catalog"]=> 224 string(%d) "%s" 225 ["max_length"]=> 226 int(0) 227 ["length"]=> 228 int(%d) 229 ["charsetnr"]=> 230 int(%d) 231 ["flags"]=> 232 int(0) 233 ["type"]=> 234 int(253) 235 ["decimals"]=> 236 int(0) 237} 238done! 239