Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 687a7ed

Browse filesBrowse files
Jean85derrabus
authored andcommitted
[Lock] Use platform to identify the PDO driver
1 parent e6e641c commit 687a7ed
Copy full SHA for 687a7ed

File tree

1 file changed

+15
-15
lines changed
Filter options

1 file changed

+15
-15
lines changed

‎src/Symfony/Component/Lock/Store/PdoStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/PdoStore.php
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function createTable(): void
295295
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)";
296296
break;
297297
default:
298-
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver));
298+
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for platform "%s".', $driver));
299299
}
300300

301301
if (method_exists($conn, 'executeStatement')) {
@@ -331,33 +331,33 @@ private function getDriver(): string
331331
$this->driver = $con->getAttribute(\PDO::ATTR_DRIVER_NAME);
332332
} else {
333333
$driver = $con->getDriver();
334+
$platform = $driver->getDatabasePlatform();
335+
336+
if ($driver instanceof \Doctrine\DBAL\Driver\Mysqli\Driver) {
337+
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
338+
}
334339

335340
switch (true) {
336-
case $driver instanceof \Doctrine\DBAL\Driver\Mysqli\Driver:
337-
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
338-
case $driver instanceof \Doctrine\DBAL\Driver\AbstractMySQLDriver:
341+
case $platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform:
342+
case $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform:
339343
$this->driver = 'mysql';
340344
break;
341-
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver:
342-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLite\Driver:
345+
case $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform:
343346
$this->driver = 'sqlite';
344347
break;
345-
case $driver instanceof \Doctrine\DBAL\Driver\PDOPgSql\Driver:
346-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\PgSQL\Driver:
348+
case $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform:
349+
case $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform:
347350
$this->driver = 'pgsql';
348351
break;
349-
case $driver instanceof \Doctrine\DBAL\Driver\OCI8\Driver:
350-
case $driver instanceof \Doctrine\DBAL\Driver\PDOOracle\Driver:
351-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\OCI\Driver:
352+
case $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform:
352353
$this->driver = 'oci';
353354
break;
354-
case $driver instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver:
355-
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver:
356-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver:
355+
case $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform:
356+
case $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform:
357357
$this->driver = 'sqlsrv';
358358
break;
359359
default:
360-
$this->driver = \get_class($driver);
360+
$this->driver = \get_class($platform);
361361
break;
362362
}
363363
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.