mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 18:34:32 +02:00
Show database name and database connection user in system infos
This commit is contained in:
parent
6eb40c6a41
commit
256926be94
4 changed files with 38 additions and 1 deletions
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue