You are here

function db_maintenance_db_size_info in DB Maintenance 5

Same name and namespace in other branches
  1. 5.2 db_maintenance.module \db_maintenance_db_size_info()

Turn bytes into something more readable like KB, MB, etc.

Return value

array

1 call to db_maintenance_db_size_info()
theme_db_maintenance_block in ./db_maintenance.module
MySQL size status by pcs305

File

./db_maintenance.module, line 256
Optimizes database tables during cron runs.

Code

function db_maintenance_db_size_info($dbsize) {
  $bytes = array(
    'KB',
    'KB',
    'MB',
    'GB',
    'TB',
  );
  if ($dbsize < 1024) {
    $dbsize = 1;
  }
  for ($i = 0; $dbsize > 1024; $i++) {
    $dbsize /= 1024;
  }
  $db_size_info['size'] = ceil($dbsize);
  $db_size_info['type'] = $bytes[$i];
  return $db_size_info;
}