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