1--TEST--
2mysqli_get_connection_stats() - disable via php.ini
3--INI--
4mysqlnd.collect_statistics="0"
5mysqlnd.collect_memory_statistics="0"
6--SKIPIF--
7<?PHP
8require_once('skipif.inc');
9require_once('skipifemb.inc');
10require_once('skipifconnectfailure.inc');
11if (!function_exists('mysqli_get_connection_stats')) {
12	die("skip only available with mysqlnd");
13}
14?>
15--FILE--
16<?php
17	// connect and table inc connect to mysql and create tables
18	require_once('connect.inc');
19
20	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
21		printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
22			$host, $user, $db, $port, $socket);
23	}
24	$before = mysqli_get_connection_stats($link);
25	if (!is_array($before) || empty($before)) {
26		printf("[002] Expecting non-empty array, got %s.\n", gettype($before));
27		var_dump($before);
28	}
29
30	mysqli_close($link);
31	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
32		printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
33			$host, $user, $db, $port, $socket);
34	}
35	$after = mysqli_get_connection_stats($link);
36
37	if ($before !== $after) {
38		printf("[004] Statistics differ!");
39		var_dump($before);
40		var_dump($after);
41	}
42
43	foreach ($after as $k => $v)
44		if ($v != 0) {
45			printf("[004] Field %s should not have any other value but 0, got %s.\n",
46				$k, $v);
47		}
48
49	mysqli_close($link);
50	print "done!";
51?>
52--EXPECTF--
53done!
54