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'; 11?> 12--FILE-- 13<?php 14 // Use the operations performed in table.inc to create some traffic on the connection 15 // so that we can collect some statistics. 16 require 'table.inc'; 17 18 if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) 19 printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 20 21 if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) 22 printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); 23 24 foreach ($info as $k => &$v) { 25 if (strpos($k, "mem_") === 0) { 26 $v = 0; 27 } 28 } 29 foreach ($info2 as $k => &$v) { 30 if (strpos($k, "mem_") === 0) { 31 $v = 0; 32 } 33 } 34 35 if ($info !== $info2) { 36 printf("[005] The hashes should be identical except of the memory related fields\n"); 37 var_dump($info); 38 var_dump($info2); 39 } 40 41 if (!is_array($info = $link->get_connection_stats()) || empty($info)) 42 printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 43 44 foreach ($info as $k => &$v) { 45 if (strpos($k, "mem_") === 0) { 46 $v = 0; 47 } 48 } 49 50 if ($info !== $info2) { 51 printf("[007] The hashes should be identical except of the memory related fields\n"); 52 var_dump($info); 53 var_dump($info2); 54 } 55 56 mysqli_close($link); 57 require 'table.inc'; 58 59 if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) 60 printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); 61 62 if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) 63 printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); 64 65 // assuming the test is run in a plain-vanilla CLI environment 66 if ($info === $info2) { 67 printf("[010] The hashes should not be identical\n"); 68 var_dump($info); 69 var_dump($info2); 70 } 71 72 print "done!"; 73?> 74--CLEAN-- 75<?php 76 require_once 'clean_table.inc'; 77?> 78--EXPECT-- 79done! 80