1--TEST--
2mysqli_fetch_assoc()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11	require('table.inc');
12
13	if (!$res = mysqli_query($link, "SELECT 1, 2")) {
14		printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
15	}
16	print "[002]\n";
17	var_dump(mysqli_fetch_assoc($res));
18	mysqli_free_result($res);
19
20	if (!$res = mysqli_query($link, "SELECT 1 AS a, 2")) {
21		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
22	}
23	print "[004]\n";
24	var_dump(mysqli_fetch_assoc($res));
25	mysqli_free_result($res);
26
27	if (!$res = mysqli_query($link, "SELECT 1 AS a, 2, 2 as '2'")) {
28		printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
29	}
30	print "[006]\n";
31	var_dump(mysqli_fetch_assoc($res));
32	mysqli_free_result($res);
33
34	if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 as '2', 2")) {
35		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
36	}
37	print "[008]\n";
38	var_dump(mysqli_fetch_assoc($res));
39	mysqli_free_result($res);
40
41	/* Now do it with unbuffered queries */
42	if (!$res = mysqli_real_query($link, "SELECT 1, 2")) {
43		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
44	}
45	if (!$res = mysqli_use_result($link)) {
46		printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
47	}
48	print "[011]\n";
49	var_dump(mysqli_fetch_assoc($res));
50	mysqli_free_result($res);
51
52	if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2")) {
53		printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
54	}
55	if (!$res = mysqli_use_result($link)) {
56		printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
57	}
58	print "[014]\n";
59	var_dump(mysqli_fetch_assoc($res));
60	mysqli_free_result($res);
61
62	if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2, 2 as '2'")) {
63		printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
64	}
65	if (!$res = mysqli_use_result($link)) {
66		printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
67	}
68	print "[017]\n";
69	var_dump(mysqli_fetch_assoc($res));
70	mysqli_free_result($res);
71
72	if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2 as '2', 2")) {
73		printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
74	}
75	if (!$res = mysqli_use_result($link)) {
76		printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
77	}
78	print "[017]\n";
79	var_dump(mysqli_fetch_assoc($res));
80	mysqli_free_result($res);
81	mysqli_close($link);
82
83	print "done!";
84?>
85--EXPECTF--
86[002]
87array(2) {
88  [1]=>
89  string(1) "1"
90  [2]=>
91  string(1) "2"
92}
93[004]
94array(2) {
95  ["a"]=>
96  string(1) "1"
97  [2]=>
98  string(1) "2"
99}
100[006]
101array(2) {
102  ["a"]=>
103  string(1) "1"
104  [2]=>
105  string(1) "2"
106}
107[008]
108array(2) {
109  ["a"]=>
110  string(1) "1"
111  [2]=>
112  string(1) "2"
113}
114[011]
115array(2) {
116  [1]=>
117  string(1) "1"
118  [2]=>
119  string(1) "2"
120}
121[014]
122array(2) {
123  ["a"]=>
124  %s(1) "1"
125  [2]=>
126  %s(1) "2"
127}
128[017]
129array(2) {
130  ["a"]=>
131  string(1) "1"
132  [2]=>
133  string(1) "2"
134}
135[017]
136array(2) {
137  ["a"]=>
138  string(1) "1"
139  [2]=>
140  string(1) "2"
141}
142done!
143