PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_tablename> <mysql_set_charset
Last updated: Fri, 18 Jul 2008

view this page in

mysql_stat

(PHP 4 >= 4.3.0, PHP 5, PECL mysql:1.0)

mysql_stat — Ottiene l'attuale stato del sistema

Descrizione

string mysql_stat ([ resource $identificativo_connessione ] )

mysql_stat() restituisce l'attuale stato del server.

Nota: mysql_stat() attualmente restituisce solo le seguenti informazioni: uptime, thread, query, tabelle aperte, tabelle svuotate e query al secondo. Per una lista completa delle altre variabili di stato si usi il comando SQL SHOW STATUS.

Example #1 mysql_stat() example

<?php
$connessione 
mysql_connect('localhost'"utente_mysql""password_mysql");
$stato explode('  'mysql_stat($connessione));
print_r($stato);
?>

L'esempio riportato sopra dovrebbe produrre il seguente output:

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
)



add a note add a note User Contributed Notes
mysql_stat
Enzo_01 at abv dot bg
31-May-2008 12:22
<?php
// function that return stat elements into array
function mysql_stat_array($A=null) {
   
$status = explode('  ', mysql_stat());
    foreach(
$status as $k=>$v) { $v=explode(':',$v,2); $status[$v[0]]=$v[1]; }
    return (isset(
$status[$A])?$status[$A]:$status);
}
/*
example return:
Array ( [0] => Uptime: 385815 [1] => Threads: 1 [2] => Questions: 3515 [3] => Slow queries: 0 [4] => Opens: 32 [5] => Flush tables: 1 [6] => Open tables: 8 [7] => Queries per second avg: 0.009 [Uptime] => Array ( [0] => Uptime [1] => 385815 ) [Threads] => Array ( [0] => Threads [1] => 1 ) [Questions] => Array ( [0] => Questions [1] => 3515 ) [Slow queries] => Array ( [0] => Slow queries [1] => 0 ) [Opens] => Array ( [0] => Opens [1] => 32 ) [Flush tables] => Array ( [0] => Flush tables [1] => 1 ) [Open tables] => Array ( [0] => Open tables [1] => 8 ) [Queries per second avg] => Array ( [0] => Queries per second avg [1] => 0.009 ) )
*/

?>
08-Feb-2005 06:16
if you need the complete status as outputted by the "show status" command. Try this function.
<?
function mysql_status($db=NULL) {
if(!mysql_ping($db))
$db=mysql_connect("localhost","user","password");
$res=mysql_query("show status",$db);
while (list($key,$value)=mysql_fetch_array($res))
$sql[$key]=$value;
return $sql;
}
?>

mysql_tablename> <mysql_set_charset
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites