xref: /PHP-8.1/ext/mysqli/tests/bug79084.phpt (revision b5a14e6c)
1--TEST--
2Bug #79084 (mysqlnd may fetch wrong column indexes with MYSQLI_BOTH)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11require_once('connect.inc');
12$sql = "SELECT 0 as `2007`, 0 as `2008`, 0 as `2020`";
13
14// unbuffered
15$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
16$link->real_query($sql);
17$res = $link->use_result();
18$row = $res->fetch_array();
19var_dump($row);
20$link->close();
21
22// buffered
23ini_set('mysqlnd.fetch_data_copy', false);
24$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
25$res = $link->query($sql);
26$row = $res->fetch_array();
27var_dump($row);
28$link->close();
29
30// buffered copies
31ini_set('mysqlnd.fetch_data_copy', true);
32$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
33$res = $link->query($sql);
34$row = $res->fetch_array();
35var_dump($row);
36$link->close();
37?>
38--EXPECT--
39array(6) {
40  [0]=>
41  string(1) "0"
42  [2007]=>
43  string(1) "0"
44  [1]=>
45  string(1) "0"
46  [2008]=>
47  string(1) "0"
48  [2]=>
49  string(1) "0"
50  [2020]=>
51  string(1) "0"
52}
53array(6) {
54  [0]=>
55  string(1) "0"
56  [2007]=>
57  string(1) "0"
58  [1]=>
59  string(1) "0"
60  [2008]=>
61  string(1) "0"
62  [2]=>
63  string(1) "0"
64  [2020]=>
65  string(1) "0"
66}
67array(6) {
68  [0]=>
69  string(1) "0"
70  [2007]=>
71  string(1) "0"
72  [1]=>
73  string(1) "0"
74  [2008]=>
75  string(1) "0"
76  [2]=>
77  string(1) "0"
78  [2020]=>
79  string(1) "0"
80}
81