mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +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
|
@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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