mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10385 from silverstripe/pulls/4.10/pdo
FIX PDO in PHP 8
This commit is contained in:
commit
8a314a90e7
@ -7,6 +7,7 @@ use SilverStripe\Dev\Deprecation;
|
|||||||
use PDO;
|
use PDO;
|
||||||
use PDOStatement;
|
use PDOStatement;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDO driver database connector
|
* PDO driver database connector
|
||||||
@ -109,10 +110,15 @@ class PDOConnector extends DBConnector implements TransactionManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate new statement
|
// Generate new statement
|
||||||
$statement = $this->pdoConnection->prepare(
|
try {
|
||||||
$sql,
|
$statement = $this->pdoConnection->prepare(
|
||||||
[PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]
|
$sql,
|
||||||
);
|
[PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]
|
||||||
|
);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$statement = false;
|
||||||
|
$this->databaseError($e->getMessage(), E_USER_ERROR, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap in a PDOStatementHandle, to cache column metadata
|
// Wrap in a PDOStatementHandle, to cache column metadata
|
||||||
$statementHandle = ($statement === false) ? false : new PDOStatementHandle($statement);
|
$statementHandle = ($statement === false) ? false : new PDOStatementHandle($statement);
|
||||||
@ -557,8 +563,13 @@ class PDOConnector extends DBConnector implements TransactionManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: $this->inTransaction may not match the 'in-transaction' state in PDO
|
||||||
$this->inTransaction = false;
|
$this->inTransaction = false;
|
||||||
return $this->pdoConnection->rollBack();
|
if ($this->pdoConnection->inTransaction()) {
|
||||||
|
return $this->pdoConnection->rollBack();
|
||||||
|
}
|
||||||
|
// return false because it did not rollback.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transactionDepth()
|
public function transactionDepth()
|
||||||
|
Loading…
Reference in New Issue
Block a user