Show database name and database connection user in system infos

This commit is contained in:
Jan Böhmer 2023-01-16 00:15:15 +01:00
parent 6eb40c6a41
commit 256926be94
4 changed files with 38 additions and 1 deletions

View file

@ -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';
}
}
}