note 26407 added to function.mysql-list-tables

From: Date: Tue, 29 Oct 2002 23:42:01 +0000
Subject: note 26407 added to function.mysql-list-tables
Groups: php.notes 
Request: Send a blank email to php-notes+get-38724@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; } ?> -- http://www.php.net/manual/en/function.mysql-list-tables.php http://master.php.net/manage/user-notes.php?action=edit+26407 http://master.php.net/manage/user-notes.php?action=delete+26407 http://master.php.net/manage/user-notes.php?action=reject+26407

« previous php.notes (#38724) next »