PHP Tutorial - PHP mysqli_get_connection_stats() Function






Definition

The mysqli_get_connection_stats() function returns statistics about the client connection.

Syntax

Object oriented style

bool mysqli::get_connection_stats ( void )

Procedural style

array mysqli_get_connection_stats ( mysqli $link )

Parameter

ParameterIs RequiredDescription
connectionRequired.MySQL connection

Return

Returns an array with connection stats if success, FALSE otherwise.

Example

The following code gets stats about the client connection.


<?php//from w ww .  j av a2  s .c  om
$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

print_r(mysqli_get_connection_stats($con));

mysqli_close($con);

$link = mysqli_connect();
print_r(mysqli_get_connection_stats($link));


?>