PHP : mysql_stat() function
Description
The mysql_stat() function is used to get current system status.
Version
(PHP 4 and above)
Syntax
mysql_stat(connection)
Parameter
| Name | Description | Required/ Optional | Type |
|---|---|---|---|
| connection | The MySQL connection. Before performing any operation on a MySQL database, it is required to set a connection to the mysql database you want to work with. And this is done by mysql_connect() function. This function takes three parameters, name of the host, username with which you want to perform tasks with the mysql database in question, and password of that user. As soon as a successful connection is established, you can perform the operations on that mysql database. In case, no such connection is found, it will try to create one without any arguments, i.e. mysql_connect() without any parameters. If it fails to connect to a mysql database, it will generate a warning (E_WARNING) but not an error. | Optional | Resource |
Return value
A string with the status for uptime, threads, queries, open tables, flush tables and queries per second.
Value Type : String
Example :
<?php
$con = mysql_connect('localhost', 'root', 'mypass');
$db_status = explode(' ', mysql_stat($con));
print_r($db_status);
?>
Output :
Array ( [0] => Uptime: 965 [1] => Threads: 1 [2] => Questions: 11 [3] => Slow queries: 0 [4] => Opens: 13 [5] => Flush tables: 1 [6] => Open tables: 7 [7] => Queries per second avg: 0.011 )
Note
Your output may vary.
See also

