1--TEST-- 2mysqli_get_connection_stats() 3--INI-- 4mysqlnd.collect_statistics="1" 5mysqlnd.collect_memory_statistics="1" 6--EXTENSIONS-- 7mysqli 8--SKIPIF-- 9<?PHP 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 require("table.inc"); 18 19 if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) 20 printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 21 22 if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) 23 printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); 24 25 foreach ($info as $k => &$v) { 26 if (strpos($k, "mem_") === 0) { 27 $v = 0; 28 } 29 } 30 foreach ($info2 as $k => &$v) { 31 if (strpos($k, "mem_") === 0) { 32 $v = 0; 33 } 34 } 35 36 if ($info !== $info2) { 37 printf("[005] The hashes should be identical except of the memory related fields\n"); 38 var_dump($info); 39 var_dump($info2); 40 } 41 42 if (!is_array($info = $link->get_connection_stats()) || empty($info)) 43 printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 44 45 foreach ($info as $k => &$v) { 46 if (strpos($k, "mem_") === 0) { 47 $v = 0; 48 } 49 } 50 51 if ($info !== $info2) { 52 printf("[007] The hashes should be identical except of the memory related fields\n"); 53 var_dump($info); 54 var_dump($info2); 55 } 56 57 mysqli_close($link); 58 require("table.inc"); 59 60 if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) 61 printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 62 63 if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) 64 printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); 65 66 // assuming the test is run in a plain-vanilla CLI environment 67 if ($info === $info2) { 68 printf("[010] The hashes should not be identical\n"); 69 var_dump($info); 70 var_dump($info2); 71 } 72 73 print "done!"; 74?> 75--CLEAN-- 76<?php 77 require_once("clean_table.inc"); 78?> 79--EXPECT-- 80done! 81