note 40165 deleted from function.mysql-query by philip
| From: | philip@php.net | Date: | Wed, 06 Apr 2005 18:06:34 +0000 |
| Subject: | note 40165 deleted from function.mysql-query by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87604@lists.php.net to get a copy of this message | ||
Note Submitter: GABZ in OZ
----
a little snippet to get the db size and all tables and all entries back! ENJOY ...
Use functions from users noted under filesize() to convert output into human readable string :))
function get_dbsize($db) {
$query = "SHOW TABLE STATUS FROM ". $db;
if ($result = mysql_query($query)) {
$tables = 0;
$rows = 0;
$size = 0;
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$rows += $row["Rows"];
$size += $row["Data_length"];
$size += $row["Index_length"];
$tables++;
}
}
$data[0] = $size;
$data[1] = $tables;
$data[2] = $rows;
return $data;
}