diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-11-12 08:30:23 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-11-12 08:30:23 +0000 |
commit | 8cea8dad029acd225e61576b1e8c6065ddcc7197 (patch) | |
tree | c75f918584a648eb3f465259a86a502f4a4cadb0 /includes | |
parent | 59ece2e39d28ba6052ea67d7770297b93a29d243 (diff) | |
download | brdo-8cea8dad029acd225e61576b1e8c6065ddcc7197.tar.gz brdo-8cea8dad029acd225e61576b1e8c6065ddcc7197.tar.bz2 |
- Patch #331213 by Damien Tournoud: make it easier to write database driver.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/database/database.inc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 59889abca..2bc67621f 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -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'; + unset($driver_options['statement_class']); + // Because the other methods don't seem to work right. $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; + // 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))); } } |