Skip to content

Commit 567d29b

Browse files
committed
fix SQLSRV throws for method_exists()
pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists(). (see microsoft/msphpsql/issues/1306) executeStatement() is a DBAL-method, exec() is PDO. fix by excluding method_exists() check on PDO type of connections
1 parent 6ca476d commit 567d29b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Store/PdoStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function createTable(): void
268268
$table->setPrimaryKey([$this->idCol]);
269269

270270
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
271-
if (method_exists($conn, 'executeStatement')) {
271+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
272272
$conn->executeStatement($sql);
273273
} else {
274274
$conn->exec($sql);
@@ -298,7 +298,7 @@ public function createTable(): void
298298
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver));
299299
}
300300

301-
if (method_exists($conn, 'executeStatement')) {
301+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
302302
$conn->executeStatement($sql);
303303
} else {
304304
$conn->exec($sql);
@@ -313,7 +313,7 @@ private function prune(): void
313313
$sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}";
314314

315315
$conn = $this->getConnection();
316-
if (method_exists($conn, 'executeStatement')) {
316+
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
317317
$conn->executeStatement($sql);
318318
} else {
319319
$conn->exec($sql);

0 commit comments

Comments
 (0)