xref: /PHP-8.3/ext/mysqli/tests/bug49027.phpt (revision 73d68693)
1--TEST--
2Bug #49027 (mysqli_options() doesn't work when using mysqlnd)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    include 'connect.inc';
12
13    $link = mysqli_init();
14    if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 1")) {
15        printf("[001] Cannot set INIT_COMMAND\n");
16    }
17
18    if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
19        printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
20    }
21
22    var_dump($link->query("SELECT 42")->fetch_row());
23
24    if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
25        !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE=%s", $engine))) {
26        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
27    }
28
29    mysqli_close($link);
30
31    $link = mysqli_init();
32    if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES(1)")) {
33        printf("[004] Cannot set INIT_COMMAND\n");
34    }
35
36    if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
37        printf("[005] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
38    }
39
40    if (!$res = mysqli_query($link, "SELECT id FROM test"))
41        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
42
43    var_dump(mysqli_fetch_assoc($res));
44
45    mysqli_free_result($res);
46    mysqli_close($link);
47
48    print "done!";
49?>
50--CLEAN--
51<?php
52    require_once 'clean_table.inc';
53?>
54--EXPECT--
55array(1) {
56  [0]=>
57  string(2) "42"
58}
59array(1) {
60  ["id"]=>
61  string(1) "1"
62}
63done!
64