1--TEST-- 2mysqli_fetch_assoc() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 // Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test 12 require 'table.inc'; 13 $mysqli = $link; 14 15 if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { 16 printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); 17 } 18 19 print "[005]\n"; 20 var_dump($res->fetch_assoc()); 21 22 print "[006]\n"; 23 var_dump($res->fetch_assoc()); 24 25 $res->free_result(); 26 27 if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { 28 printf("[007] Cannot run query, [%d] %s\n", $mysqli->errno, $mysqli->error); 29 } 30 print "[008]\n"; 31 var_dump($res->fetch_assoc()); 32 33 $res->free_result(); 34 35 try { 36 $res->fetch_assoc(); 37 } catch (Error $exception) { 38 echo $exception->getMessage() . "\n"; 39 } 40 41 mysqli_close($link); 42 43 print "done!"; 44?> 45--CLEAN-- 46<?php 47 require_once 'clean_table.inc'; 48?> 49--EXPECT-- 50[005] 51array(2) { 52 ["id"]=> 53 string(1) "1" 54 ["label"]=> 55 string(1) "a" 56} 57[006] 58NULL 59[008] 60array(5) { 61 ["a"]=> 62 string(1) "2" 63 ["c"]=> 64 string(1) "3" 65 ["C"]=> 66 string(1) "4" 67 ["d"]=> 68 NULL 69 ["e"]=> 70 string(1) "1" 71} 72mysqli_result object is already closed 73done! 74