mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-11 10:54:34 +02:00
Show database size in system info tool
This commit is contained in:
parent
706253ce74
commit
6eb40c6a41
4 changed files with 47 additions and 0 deletions
|
@ -73,4 +73,32 @@ class DBInfoHelper
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database size in bytes.
|
||||
* @return int|null The database size in bytes or null if unknown
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
*/
|
||||
public function getDatabaseSize(): ?int
|
||||
{
|
||||
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
|
||||
try {
|
||||
return $this->connection->fetchOne('SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = DATABASE()');
|
||||
} catch (\Doctrine\DBAL\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
|
||||
try {
|
||||
return $this->connection->fetchOne('SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size();');
|
||||
} catch (\Doctrine\DBAL\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue