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