diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-08-19 10:57:49 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-08-19 11:00:08 +0300 |
commit | 22d8450e2deafb0a5473515f4ef01e8b3143514f (patch) | |
tree | 6979568c5980c370b82adeff26e96f491c8322dd | |
parent | 0a11424d1a7b351e7a53c2521b04293984ee271c (diff) |
Fix size calculation for MariaDB
-rw-r--r-- | lib/DatabaseStatistics.php | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/DatabaseStatistics.php b/lib/DatabaseStatistics.php index 88c9557..b1a663c 100644 --- a/lib/DatabaseStatistics.php +++ b/lib/DatabaseStatistics.php @@ -92,26 +92,16 @@ class DatabaseStatistics { // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 switch ($this->config->getSystemValue('dbtype')) { case 'mysql': - $sql = 'SELECT VERSION() AS mysql_version'; + $db_name = $this->config->getSystemValue('dbname'); + $sql = 'SHOW TABLE STATUS FROM ' . $db_name; $result = $this->connection->executeQuery($sql); - $row = $result->fetch(); - $result->closeCursor(); - if ($row) { - $version = $row['mysql_version']; - if (preg_match('#(3\.23|[45]\.)#', $version)) { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$this->config->getSystemValue('dbname')}`" : $this->config->getSystemValue('dbname'); - $sql = 'SHOW TABLE STATUS - FROM ' . $db_name; - $result = $this->connection->executeQuery($sql); - $database_size = 0; - while ($row = $result->fetch()) { - if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB'))) { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - $result->closeCursor(); + $database_size = 0; + while ($row = $result->fetch()) { + if ((isset($row['Type']) && $row['Type'] !== 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB'))) { + $database_size += $row['Data_length'] + $row['Index_length']; } } + $result->closeCursor(); break; case 'sqlite': case 'sqlite3': |