function DoctrineDbalPostgreSqlStore::__construct
You can either pass an existing database connection a Doctrine DBAL Connection or a URL that will be used to connect to the database.
Throws
InvalidArgumentException When first argument is not Connection nor string
File
-
vendor/
symfony/ lock/ Store/ DoctrineDbalPostgreSqlStore.php, line 44
Class
- DoctrineDbalPostgreSqlStore
- DoctrineDbalPostgreSqlStore is a PersistingStoreInterface implementation using PostgreSql advisory locks with a Doctrine DBAL Connection.
Namespace
Symfony\Component\Lock\StoreCode
public function __construct(Connection|string $connOrUrl) {
if ($connOrUrl instanceof Connection) {
if (!$connOrUrl->getDatabasePlatform() instanceof PostgreSQLPlatform) {
throw new InvalidArgumentException(\sprintf('The adapter "%s" does not support the "%s" platform.', __CLASS__, $connOrUrl->getDatabasePlatform()::class));
}
$this->conn = $connOrUrl;
}
else {
if (!class_exists(DriverManager::class)) {
throw new InvalidArgumentException('Failed to parse DSN. Try running "composer require doctrine/dbal".');
}
$params = (new DsnParser([
'db2' => 'ibm_db2',
'mssql' => 'pdo_sqlsrv',
'mysql' => 'pdo_mysql',
'mysql2' => 'pdo_mysql',
'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
]))->parse($this->filterDsn($connOrUrl));
$config = new Configuration();
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
$this->conn = DriverManager::getConnection($params, $config);
}
}