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