function DatabaseConnection::__construct

3 calls to DatabaseConnection::__construct()
DatabaseConnection_mysql::__construct in includes/database/mysql/database.inc
DatabaseConnection_pgsql::__construct in includes/database/pgsql/database.inc
DatabaseConnection_sqlite::__construct in includes/database/sqlite/database.inc
3 methods override DatabaseConnection::__construct()
DatabaseConnection_mysql::__construct in includes/database/mysql/database.inc
DatabaseConnection_pgsql::__construct in includes/database/pgsql/database.inc
DatabaseConnection_sqlite::__construct in includes/database/sqlite/database.inc

File

includes/database/database.inc, line 327

Class

DatabaseConnection
Base Database API class.

Code

function __construct($dsn, $username, $password, $driver_options = array()) {
    // Initialize and prepare the connection prefix.
    $this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : '');
    // Because the other methods don't seem to work right.
    $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
    // Call PDO::__construct and PDO::setAttribute.
    $this->connection = new PDO($dsn, $username, $password, $driver_options);
    // Set a Statement class, unless the driver opted out.
    if (!empty($this->statementClass)) {
        $this->connection
            ->setAttribute(PDO::ATTR_STATEMENT_CLASS, array(
            $this->statementClass,
            array(
                $this,
            ),
        ));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.