PHP mysql_stat() 函数

定义和用法

mysql_stat() 函数返回 MySQL 服务器的当前系统状态。

如果成功,则该函数返回状态。如果失败,则返回 false。

语法

mysql_stat(connection)
参数 描述
connection 可选。规定 MySQL 连接。如果未指定,则使用上一个连接。

提示和注释

注释:mysql_stat() 目前只返回 uptime、threads、queries、open tables、flush tables 和 queries per second。要得到其它状态变量的完整列表,只能使用 SQL 命令 SHOW STATUS。

例子

<?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();
?>

输出类似:

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