Example #1
0
 /**
  * Constructs a \Drupal\Core\Database\Driver\sqlite\Connection object.
  */
 public function __construct(\PDO $connection, array $connection_options)
 {
     parent::__construct($connection, $connection_options);
     // We don't need a specific PDOStatement class here, we simulate it below.
     $this->statementClass = NULL;
     // This driver defaults to transaction support, except if explicitly passed FALSE.
     $this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
     $this->connectionOptions = $connection_options;
     // Attach one database for each registered prefix.
     $prefixes = $this->prefixes;
     foreach ($prefixes as &$prefix) {
         // Empty prefix means query the main database -- no need to attach anything.
         if (!empty($prefix)) {
             // Only attach the database once.
             if (!isset($this->attachedDatabases[$prefix])) {
                 $this->attachedDatabases[$prefix] = $prefix;
                 $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix));
             }
             // Add a ., so queries become prefix.table, which is proper syntax for
             // querying an attached database.
             $prefix .= '.';
         }
     }
     // Regenerate the prefixes replacement table.
     $this->setPrefix($prefixes);
     // Detect support for SAVEPOINT.
     $version = $this->query('SELECT sqlite_version()')->fetchField();
     $this->savepointSupport = version_compare($version, '3.6.8') >= 0;
 }
Example #2
0
 /**
  * Constructs a \Drupal\Core\Database\Driver\sqlite\Connection object.
  */
 public function __construct(\PDO $connection, array $connection_options)
 {
     // We don't need a specific PDOStatement class here, we simulate it in
     // static::prepare().
     $this->statementClass = NULL;
     parent::__construct($connection, $connection_options);
     // This driver defaults to transaction support, except if explicitly passed FALSE.
     $this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
     $this->connectionOptions = $connection_options;
     // Attach one database for each registered prefix.
     $prefixes = $this->prefixes;
     foreach ($prefixes as &$prefix) {
         // Empty prefix means query the main database -- no need to attach anything.
         if (!empty($prefix)) {
             // Only attach the database once.
             if (!isset($this->attachedDatabases[$prefix])) {
                 $this->attachedDatabases[$prefix] = $prefix;
                 if ($connection_options['database'] === ':memory:') {
                     // In memory database use ':memory:' as database name. According to
                     // http://www.sqlite.org/inmemorydb.html it will open a unique
                     // database so attaching it twice is not a problem.
                     $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'], ':prefix' => $prefix));
                 } else {
                     $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix));
                 }
             }
             // Add a ., so queries become prefix.table, which is proper syntax for
             // querying an attached database.
             $prefix .= '.';
         }
     }
     // Regenerate the prefixes replacement table.
     $this->setPrefix($prefixes);
 }
 /**
  * Constructs a Connection object.
  */
 public function __construct(\PDO $connection, array $connection_options = array())
 {
     parent::__construct($connection, $connection_options);
     // This driver defaults to transaction support, except if explicitly passed FALSE.
     $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
     // MySQL never supports transactional DDL.
     $this->transactionalDDLSupport = FALSE;
     $this->connectionOptions = $connection_options;
 }
Example #4
0
 /**
  * Constructs a connection object.
  */
 public function __construct(\PDO $connection, array $connection_options)
 {
     parent::__construct($connection, $connection_options);
     // This driver defaults to transaction support, except if explicitly passed FALSE.
     $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
     // Transactional DDL is always available in PostgreSQL,
     // but we'll only enable it if standard transactions are.
     $this->transactionalDDLSupport = $this->transactionSupport;
     $this->connectionOptions = $connection_options;
     // Force PostgreSQL to use the UTF-8 character set by default.
     $this->connection->exec("SET NAMES 'UTF8'");
     // Execute PostgreSQL init_commands.
     if (isset($connection_options['init_commands'])) {
         $this->connection->exec(implode('; ', $connection_options['init_commands']));
     }
 }
Example #5
0
  /**
   * Constructs a Connection object.
   */
  public function __construct(\PDO $connection, array $connection_options) {
    // Needs to happen before parent construct.
    $this->statementClass = Statement::class;
    
    parent::__construct($connection, $connection_options);  
    
    // This driver defaults to transaction support, except if explicitly passed FALSE.
    $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;
    $this->transactionalDDLSupport = $this->transactionSupport;

    // Store connection options for future reference.
    $this->connectionOptions = &$connection_options;
    
    // Fetch the name of the user-bound schema. It is the schema that SQL Server
    // will use for non-qualified tables.
    $this->schema()->defaultSchema = $this->schema()->GetDefaultSchema();

    // Set default direct query behaviour
    $this->directQuery = TRUE;//DatabaseUtils::GetConfigBoolean('MSSQL_DEFAULT_DIRECTQUERY');
    $this->statementCaching = DatabaseUtils::GetConfigBoolean('MSSQL_STATEMENT_CACHING');
  }