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