PHP mysql_stat() Function

Definition and Usage

The mysql_stat() function returns the current system status of the MySQL server.

If successful, the function returns the status. If failed, it returns false.

Syntax

mysql_stat(connection)
Parameters Description
connection Optional. Specifies the MySQL connection. If not specified, the previous connection is used.

Tips and Comments

Note:mysql_stat() currently returns only uptime, threads, queries, open tables, flush tables, and queries per second. To get a complete list of other status variables, you can only use the SQL command SHOW STATUS.

Example

<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db", $con);
echo mysql_stat();
?>

Output similar to:

Uptime: 99410 Threads: 1 Questions: 162
Slow queries: 0 Opens: 0 Flush tables: 1
Open tables: 0 Queries per second avg: 0.002