Introduction
In this article I describe the PHP MySQLi functions mysqli_get_client_stats, mysqli_get_client_version, mysqli_get_connection_stats, mysqli_get_host_info and mysqli-get_proto_info. To learn some other MySQLi functions, go to:
- MySQLi Function in PHP: Part 1
- MySQLi Function in PHP: Part 2
- MySQLi Function in PHP: Part 3
- MySQLi Function in PHP: Part 4
- MySQLi Function in PHP: Part 5
- MySQLi Function in PHP: Part 6
PHP mysqli_get_client_stats() Function
The PHP MySQLi "mysqli_client_stats" function returns client per-process statistics or in other words this function returns an array with client stats if success otherwise it returns false.
Syntax
mysqli_get_client_stats() |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "<pre>";
print_r(mysqli_get_client_stats());
mysqli_close($con);
?>
Output
PHP mysqli_get_client_version() Function
The PHP MySQLi "mysqli_client_version" function returns the MySQL client version as a string or in other words this function returns a number that represents the mysqli client library version in format.
Syntax
mysqli_get_client_version(connection) |
Parameter in mysqli_get_client_version function
The parameter of the function is:
Parameter |
Description |
connection |
It specifies MySQL connection to use. |
Example
An example of the function is:
<?php
echo mysqli_get_client_version();
?>
Output
PHP mysqli_get_connection_stats() Function
The PHP MySQLi "mysqli_connection_stats" function returns statistics about the client connection or in other words this function returns an array with connection stats if success or false on failure.
Syntax
mysqli_get_connection_stats(connection) |
Parameter in mysqli_get_connection_stats function
The parameter of the function is:
Parameter |
Description |
connection |
It specifies the MySQL connection to use. |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "<pre>";
print_r(mysqli_get_connection_stats($con));
mysqli_close($con);
?>
Output
PHP mysqli_get_host_info() Function
The PHP MySQLi "mysqli_get_host_info" function returns a string representing the type of connection used or in other words this function returns a character string representing the server hostname and the connection type.
Syntax
mysqli_get_host_info(connection) |
Parameter in mysqli_get_host_info function
The parameter of the function is:
Parameter |
Description |
connection |
It specifies the MySQL connection to use. |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
print_r(mysqli_get_host_info($con));
mysqli_close($con);
?>
Output
PHP mysqli_get_proto_info() Function
The PHP MySQLi "mysqli_get_proto_info" function returns the version of the MySQL protocol used or in other words this function returns an integer representing the MySQL protocol version used by the connection represented by a parameter.
Syntax
mysqli_get_proto_info(connection) |
Parameter in mysqli_get_proto_info function
The parameter of the function is:
Parameter |
Description |
connection |
It specifies the MySQL connection to use. |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo mysqli_get_proto_info($con);
mysqli_close($con);
?>
Output