PHP mysql_stat() 函數(shù)
定義和用法
mysql_stat() 函數(shù)返回 MySQL 服務(wù)器的當(dāng)前系統(tǒng)狀態(tài)。
如果成功,則該函數(shù)返回狀態(tài)。如果失敗,則返回 false。
語法
mysql_stat(connection)
參數(shù) | 描述 |
---|---|
connection | 可選。規(guī)定 MySQL 連接。如果未指定,則使用上一個(gè)連接。 |
提示和注釋
注釋:mysql_stat() 目前只返回 uptime、threads、queries、open tables、flush tables 和 queries per second。要得到其它狀態(tài)變量的完整列表,只能使用 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