Commit 18d7b9d0 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add function to get db size


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 1daeff70
......@@ -83,6 +83,27 @@ function db_is_utf8() {
return false;
}
function db_total_size() {
global $db;
if (!is_a($db, 'ADOConnection')) {
throw new SQLException('Database connection is not available ');
}
$dbname = db_quote(get_config('dbname'));
if (is_mysql()) {
$result = $db->Execute("
SELECT SUM( data_length + index_length ) AS dbsize
FROM information_schema.tables
WHERE table_schema = $dbname
");
return $result->fields['dbsize'];
}
if (is_postgres()) {
$result = $db->Execute("SELECT * FROM pg_database_size($dbname)");
return $result->fields['pg_database_size'];
}
return false;
}
function column_collation_is_default($table, $column) {
global $db;
if (!is_a($db, 'ADOConnection')) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment