コード例 #1
0
<?php

// connect and table inc connect to mysql and create tables
require_once 'connect.inc';
if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
$before = mysqli_get_connection_stats($link);
if (!is_array($before) || empty($before)) {
    printf("[002] Expecting non-empty array, got %s.\n", gettype($before));
    var_dump($before);
}
mysqli_close($link);
if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
$after = mysqli_get_connection_stats($link);
if ($before !== $after) {
    printf("[004] Statistics differ!");
    var_dump($before);
    var_dump($after);
}
foreach ($after as $k => $v) {
    if ($v != 0) {
        printf("[004] Field %s should not have any other value but 0, got %s.\n", $k, $v);
    }
}
mysqli_close($link);
print "done!";
コード例 #2
0
if (!is_array($info = $link->get_connection_stats()) || empty($info)) {
    printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
}
foreach ($info as $k => &$v) {
    if (strpos($k, "mem_") === 0) {
        $v = 0;
    }
}
if ($info !== $info2) {
    printf("[007] The hashes should be identical except of the memory related fields\n");
    var_dump($info);
    var_dump($info2);
}
mysqli_close($link);
$test_table_name = 'test_mysqli_get_connection_stats_table_1';
require "table.inc";
if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) {
    printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
}
if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) {
    printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
}
// assuming the test is run in a plain-vanilla CLI environment
if ($info === $info2) {
    printf("[010] The hashes should not be identical\n");
    var_dump($info);
    var_dump($info2);
}
print "done!";
$test_table_name = 'test_mysqli_get_connection_stats_table_1';
require_once "clean_table.inc";
コード例 #3
0
ファイル: mysql.php プロジェクト: oliverhale/Cream
 public function ConnnectionStat()
 {
     $this->stat = mysqli_get_connection_stats($GLOBALS['connection']);
 }