note 46705 deleted from function.mysql-stat by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 20 Oct 2004 22:33:05 +0000 |
| Subject: | note 46705 deleted from function.mysql-stat by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78858@lists.php.net to get a copy of this message | ||
Note Submitter: anthony dot parsons at manx dot _net
----
The mysql_stat function only returns a string, so I wrote a function to convert the output into an
associative array:
<?php
//Usage is identical to mysql_stat, but returns the values as a 1D array instead of a string
function mysql_array_stat ($db = null)
{
$stat = $db ? mysql_stat ($db) : mysql_stat();
foreach (explode (' ', $stat) as $value)
{
$x = explode (': ', $value);
$stat_array[$x[0]] = $x[1];
}
return $stat_array;
}
?>
A print_r(mysql_array_stat()) would look like this:
Array
(
[Uptime] => 150062
[Threads] => 3
[Questions] => 9177
[Slow queries] => 0
[Opens] => 409
[Flush tables] => 1
[Open tables] => 11
[Queries per second avg] => 0.061
)