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
13    require 'table.inc';
14    if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) {
15        printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16    }
17
18    print "[005]\n";
19    var_dump(mysqli_fetch_assoc($res));
20
21    print "[006]\n";
22    var_dump(mysqli_fetch_assoc($res));
23
24    mysqli_free_result($res);
25
26    if (!$res = mysqli_query($link, "SELECT
27        1 AS a,
28        2 AS a,
29        3 AS c,
30        4 AS C,
31        NULL AS d,
32        true AS e,
33        5 AS '-1',
34        6 AS '-10',
35        7 AS '-100',
36        8 AS '-1000',
37        9 AS '10000',
38        'a' AS '100000',
39        'b' AS '1000000',
40        'c' AS '9',
41        'd' AS '9',
42        'e' AS '01',
43        'f' AS '-02'
44    ")) {
45        printf("[007] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
46    }
47    print "[008]\n";
48    var_dump(mysqli_fetch_assoc($res));
49
50    mysqli_free_result($res);
51
52    try {
53        mysqli_fetch_assoc($res);
54    } catch (Error $exception) {
55        echo $exception->getMessage() . "\n";
56    }
57
58    mysqli_close($link);
59
60    print "done!";
61?>
62--CLEAN--
63<?php
64    require_once 'clean_table.inc';
65?>
66--EXPECT--
67[005]
68array(2) {
69  ["id"]=>
70  string(1) "1"
71  ["label"]=>
72  string(1) "a"
73}
74[006]
75NULL
76[008]
77array(15) {
78  ["a"]=>
79  string(1) "2"
80  ["c"]=>
81  string(1) "3"
82  ["C"]=>
83  string(1) "4"
84  ["d"]=>
85  NULL
86  ["e"]=>
87  string(1) "1"
88  [-1]=>
89  string(1) "5"
90  [-10]=>
91  string(1) "6"
92  [-100]=>
93  string(1) "7"
94  [-1000]=>
95  string(1) "8"
96  [10000]=>
97  string(1) "9"
98  [100000]=>
99  string(1) "a"
100  [1000000]=>
101  string(1) "b"
102  [9]=>
103  string(1) "d"
104  ["01"]=>
105  string(1) "e"
106  ["-02"]=>
107  string(1) "f"
108}
109mysqli_result object is already closed
110done!
111