Current Location: Home> Function Categories> mysql_stat

mysql_stat

Get the current system status.
Name:mysql_stat
Category:Uncategorized
Programming Language:php
One-line Description:Return the status information of the current MySQL server

Function name: mysql_stat()

Applicable version: PHP 4, PHP 5, PHP 7

Function description: the mysql_stat() function returns the status information of the current MySQL server.

usage:

 string mysql_stat ([ resource $link_identifier = NULL ] )

parameter:

  • link_identifier (optional): MySQL connection identifier. If this parameter is not provided, the function tries to find the previously opened connection. If the appropriate connection is not found, a connection is attempted by calling mysql_connect() .

Return Value: Returns a string describing the status of the MySQL server. The format of the string is "Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %f".

Example:

 $link = mysql_connect('localhost', 'username', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); } $stat = mysql_stat($link); echo "MySQL Server Status: " . $stat; mysql_close($link);

Output example:

 MySQL Server Status: Uptime: 12345 Threads: 5 Questions: 10000 Slow queries: 2 Opens: 50 Flush tables: 1 Open tables: 10 Queries per second avg: 5.678

Notes:

  • mysql_stat() function can only be used for MySQL extensions (mysql), and not for MySQLi extensions (mysqli) or PDO extensions.
  • In PHP 5.5.0 and later, it is no longer recommended to use the mysql_ function, but to use MySQLi or PDO to connect and operate the MySQL database.
Similar Functions
Popular Articles