note 26407 deleted from function.mysql-list-tables by goba

From: Date: Wed, 30 Oct 2002 08:18:27 +0000
Subject: note 26407 deleted from function.mysql-list-tables by goba
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38731@lists.php.net to get a copy of this message
<? /* Function that returns whole size of a given MySQL database Returns false if no db by that name is found */ function getdbsize($tdb) { $db_host='localhost'; $db_usr='USER'; $db_pwd='XXXXXXXX'; $db = mysql_connect($db_host, $db_usr, $db_pwd) or die ("Error connecting to MySQL Server!\n"); mysql_select_db($tdb, $db); $sql_result = "SHOW TABLE STATUS FROM " .$tdb; $result = mysql_query($sql_result); mysql_close($db); if($result) { $size = 0; while ($data = mysql_fetch_array($result)) { $size = $size + $data["Data_length"] + $data["Index_length"]; } return $size; } else { return FALSE; } } ?> <? /* Implementation example */ $tmp = getdbsize("DATABASE_NAME"); if (!$tmp) { echo "ERROR!"; } else { echo $tmp; } ?>

« previous php.notes (#38731) next »