diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index d3bb0423..542b5722 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -87,6 +87,8 @@ class ToolsController extends AbstractController 'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown', 'db_version' => $DBInfoHelper->getDatabaseVersion() ?? 'Unknown', 'db_size' => $DBInfoHelper->getDatabaseSize(), + 'db_name' => $DBInfoHelper->getDatabaseName() ?? 'Unknown', + 'db_user' => $DBInfoHelper->getDatabaseUsername() ?? 'Unknown', ]); } diff --git a/src/Services/Misc/DBInfoHelper.php b/src/Services/Misc/DBInfoHelper.php index 5f377997..2ae09ccc 100644 --- a/src/Services/Misc/DBInfoHelper.php +++ b/src/Services/Misc/DBInfoHelper.php @@ -100,5 +100,32 @@ class DBInfoHelper return null; } + /** + * Returns the name of the database. + * @return string|null + */ + public function getDatabaseName(): ?string + { + return $this->connection->getDatabase() ?? null; + } + + /** + * Returns the name of the database user. + * @return string|null + */ + public function getDatabaseUsername(): ?string + { + if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) { + try { + return $this->connection->fetchOne('SELECT USER()'); + } catch (\Doctrine\DBAL\Exception $e) { + return null; + } + } + + if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { + return 'sqlite'; + } + } } \ No newline at end of file diff --git a/templates/Tools/ServerInfos/_db.html.twig b/templates/Tools/ServerInfos/_db.html.twig index d146b129..0c0e60a2 100644 --- a/templates/Tools/ServerInfos/_db.html.twig +++ b/templates/Tools/ServerInfos/_db.html.twig @@ -13,5 +13,13 @@