Commit 8cea8dad authored by Dries's avatar Dries
Browse files

- Patch #331213 by Damien Tournoud: make it easier to write database driver.

parent 59ece2e3
......@@ -218,16 +218,19 @@ abstract class DatabaseConnection extends PDO {
protected $schema = NULL;
function __construct($dsn, $username, $password, $driver_options = array()) {
// Merge in defaults.
$driver_options += array(
'statement_class' => 'DatabaseStatementBase',
// Fallback to DatabaseStatementBase if the driver has not specified one.
$statement_class = isset($driver_options['statement_class']) ? $driver_options['statement_class'] : 'DatabaseStatementBase';
// Because the other methods don't seem to work right.
// Call PDO::__construct and PDO::setAttribute.
parent::__construct($dsn, $username, $password, $driver_options);
if (!empty($driver_options['statement_class'])) {
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($driver_options['statement_class'], array($this)));
// Set a specific PDOStatement class if the driver requires that.
if (!empty($statement_class)) {
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($statement_class, array($this)));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment