array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.mysql-stat.php', 1 => 'mysql_stat', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'Funções da MySQL', ), 'prev' => array ( 0 => 'function.mysql-set-charset.php', 1 => 'mysql_set_charset', ), 'next' => array ( 0 => 'function.mysql-tablename.php', 1 => 'mysql_tablename', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mysql/functions/mysql-stat.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5)
mysql_stat — Get current system status
Esta extensão tornou-se defasada a partir do PHP 5.5.0 e foi removida no PHP 7.0.0. Em vez disso, as extensões MySQLi ou PDO_MySQL devem ser usadas. Veja também o guia MySQL: escolhendo uma API. Alternativas a esta função incluem:
attribute
as PDO::ATTR_SERVER_INFO
mysql_stat() returns the current server status.
link_identifier
A conexão MySQL. Se o
identificador da conexão não for especificado, a última conexão aberta por
mysql_connect() será usada. Se não houver uma conexão anterior,
haverá uma tentativa de criar uma como se mysql_connect() tivesse sido chamada
sem argumentos. Se nenhuma conexão for encontrada ou estabelecida, um erro de nível
E_WARNING
será gerado.
Returns a string with the status for uptime, threads, queries, open tables,
flush tables and queries per second. For a complete list of other status
variables, you have to use the SHOW STATUS
SQL command.
If link_identifier
is invalid, null
is returned.
Exemplo #1 mysql_stat() example
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$status = explode(' ', mysql_stat($link));
print_r($status);
?>
O exemplo acima produzirá algo semelhante a:
Array ( [0] => Uptime: 5380 [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 )
Exemplo #2 Alternative mysql_stat() example
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$result = mysql_query('SHOW STATUS', $link);
while ($row = mysql_fetch_assoc($result)) {
echo $row['Variable_name'] . ' = ' . $row['Value'] . "\n";
}
?>
O exemplo acima produzirá algo semelhante a:
back_log = 50 basedir = /usr/local/ bdb_cache_size = 8388600 bdb_log_buffer_size = 32768 bdb_home = /var/db/mysql/ bdb_max_lock = 10000 bdb_logdir = bdb_shared_data = OFF bdb_tmpdir = /var/tmp/ ...