當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::__construct方法代碼示例

本文整理匯總了PHP中Drupal\Core\Database\Connection::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::__construct方法的具體用法?PHP Connection::__construct怎麽用?PHP Connection::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Database\Connection的用法示例。


在下文中一共展示了Connection::__construct方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * 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;
 }
開發者ID:anyforsoft,項目名稱:csua_d8,代碼行數:32,代碼來源:Connection.php

示例2: __construct

 /**
  * 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);
 }
開發者ID:papillon-cendre,項目名稱:d8,代碼行數:37,代碼來源:Connection.php

示例3: __construct

 /**
  * 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;
 }
開發者ID:penguinclub,項目名稱:penguinweb_drupal8,代碼行數:12,代碼來源:Connection.php

示例4: __construct

 /**
  * 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']));
     }
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:19,代碼來源:Connection.php

示例5: __construct

  /**
   * 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');
  }
開發者ID:HamzaBendidane,項目名稱:prel,代碼行數:24,代碼來源:Connection.php


注:本文中的Drupal\Core\Database\Connection::__construct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。