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