mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed DBInfoHelper compatibility with postgres
This commit is contained in:
parent
a88a2e04cf
commit
dc14b58d73
1 changed files with 25 additions and 0 deletions
|
@ -25,6 +25,7 @@ namespace App\Services\Misc;
|
||||||
use Doctrine\DBAL\Exception;
|
use Doctrine\DBAL\Exception;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||||
|
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
@ -54,6 +55,10 @@ class DBInfoHelper
|
||||||
return 'sqlite';
|
return 'sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
|
||||||
|
return 'postgresql';
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +76,10 @@ class DBInfoHelper
|
||||||
return $this->connection->fetchOne('SELECT sqlite_version()');
|
return $this->connection->fetchOne('SELECT sqlite_version()');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
|
||||||
|
return $this->connection->fetchOne('SELECT version()');
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +106,14 @@ class DBInfoHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
|
||||||
|
try {
|
||||||
|
return (int) $this->connection->fetchOne('SELECT pg_database_size(current_database())');
|
||||||
|
} catch (Exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +142,14 @@ class DBInfoHelper
|
||||||
return 'sqlite';
|
return 'sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
|
||||||
|
try {
|
||||||
|
return $this->connection->fetchOne('SELECT current_user');
|
||||||
|
} catch (Exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue