PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




mysql_stat() function for PHP


Tutorials »Php »

Topic

What is mysql_stat() function in PHP?
How does mysql_stat() works?




Explanation

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

Syntax

string mysql_stat ( [ resource link_identifier ])


Returns status on success, or NULL on failure.

mysql_stat() returns current server status. mysql_stat() returns status for uptime, threads, open tables, flush tables and queries per second.

Example:


<?php

$link = mysql_pconnect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

$status = explode(' ', mysql_stat($link));
print_r($status);
?>



RESULT:

Array
(
[0] => Uptime: 99410
[1] => Threads: 2
[2] => Questions: 1321299
[3] => Slow queries: 0
[4] => Opens: 26
[5] => Flush tables: 1
[6] => Open tables: 17
[7] => Queries per second avg: 245.595
)

For a complete list of other status variables you have to use the SHOW STATUS SQL command.

Example


<?php

$link = mysql_pconnect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

$result = mysql_query('SHOW STATUS', $link);
while ($row = mysql_fetch_assoc($result)) {
echo $row['Variable_name'] . ' = ' . $row['Value'] . "<br>";
}
?>



RESULT:

Aborted_clients = 0
Aborted_connects = 0
Binlog_cache_disk_use = 0
Binlog_cache_use = 0
Bytes_received = 144
Bytes_sent = 15855
Com_admin_commands = 0
Com_alter_db = 0
Com_alter_table = 0
Com_analyze = 0
Com_backup_table = 0
Com_begin = 0
Com_change_db = 0
Com_change_master = 0
Com_check = 0
Com_checksum = 0
Com_commit = 0
Com_create_db = 0
Com_create_function = 0
Com_create_index = 0
Com_create_table = 0
.....
.....etc




Other Links

web hosting