__construct() 공개 메소드

Initializes a new instance of the Connection class.
public __construct ( array $params, Doctrine\DBAL\Driver $driver, Doctrine\DBAL\Configuration $config = null, Doctrine\Common\EventManager $eventManager = null )
$params array The connection parameters.
$driver Doctrine\DBAL\Driver The driver to use.
$config Doctrine\DBAL\Configuration The configuration, optional.
$eventManager Doctrine\Common\EventManager The event manager, optional.
예제 #1
0
 /**
  *
  * @param array                              $params
  * @param \Doctrine\DBAL\Driver              $driver
  * @param \Doctrine\DBAL\Configuration|null  $config
  * @param \Doctrine\Common\EventManager|null $eventManager
  */
 public function __construct(array $params, $driver, $config = null, $eventManager = null)
 {
     $this->_platformMock = new DatabasePlatformMock();
     parent::__construct($params, $driver, $config, $eventManager);
     // Override possible assignment of platform to database platform mock
     $this->_platform = $this->_platformMock;
 }
 /**
  * @param array $params
  * @param Driver|ServerGoneAwayExceptionsAwareInterface $driver
  * @param Configuration $config
  * @param EventManager $eventManager
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if ($driver instanceof ServerGoneAwayExceptionsAwareInterface && isset($params['driverOptions']['x_reconnect_attempts'])) {
         $this->reconnectAttempts = (int) $params['driverOptions']['x_reconnect_attempts'];
     }
     parent::__construct($params, $driver, $config, $eventManager);
 }
 /**
  * @param array $params
  * @param Driver $driver
  * @param Configuration $config
  * @param EventManager $eventManager
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (isset($params['driverOptions']['x_reconnect_attempts']) && method_exists($driver, 'getReconnectExceptions')) {
         $reconnectExceptions = $driver->getReconnectExceptions();
         $this->reconnectAttempts = empty($reconnectExceptions) ? 0 : (int) $params['driverOptions']['x_reconnect_attempts'];
     }
     parent::__construct($params, $driver, $config, $eventManager);
 }
 /**
  * Initializes a new instance of the Connection class.
  *
  * @param array         $params
  * @param Driver        $driver
  * @param Configuration $config
  * @param EventManager  $eventManager
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     parent::__construct($params, $driver, $config, $eventManager);
     if (isset($params['prefix'])) {
         $this->prefix = $params['prefix'];
     }
     $this->regex['quotes'] = "/([^'\"]+)(?:" . self::DOUBLE_QUOTED_TEXT . "|" . self::SINGLE_QUOTED_TEXT . ")?/As";
     $this->regex['placeholder'] = "/" . preg_quote($this->placeholder) . "([a-zA-Z_][a-zA-Z0-9_]*)/";
 }
 /**
  * @param array                                         $params
  * @param Driver|ServerGoneAwayExceptionsAwareInterface $driver
  * @param Configuration                                 $config
  * @param EventManager                                  $eventManager
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!$driver instanceof ServerGoneAwayExceptionsAwareInterface) {
         throw new \InvalidArgumentException(sprintf('%s needs a driver that implements ServerGoneAwayExceptionsAwareInterface', get_class($this)));
     }
     if (isset($params['driverOptions']['x_reconnect_attempts'])) {
         $this->reconnectAttempts = (int) $params['driverOptions']['x_reconnect_attempts'];
     }
     parent::__construct($params, $driver, $config, $eventManager);
 }
예제 #6
0
 /**
  * Initializes a new instance of the Connection class.
  *
  * @param array $params  The connection parameters.
  * @param \Doctrine\DBAL\Driver $driver
  * @param \Doctrine\DBAL\Configuration $config
  * @param \Doctrine\Common\EventManager $eventManager
  * @throws \Exception
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!isset($params['adapter'])) {
         throw new \Exception('adapter not set');
     }
     if (!isset($params['tablePrefix'])) {
         throw new \Exception('tablePrefix not set');
     }
     parent::__construct($params, $driver, $config, $eventManager);
     $this->adapter = new $params['adapter']($this);
     $this->tablePrefix = $params['tablePrefix'];
 }
예제 #7
0
 /**
  * Initializes a new instance of the Connection class.
  *
  * @param array         $params
  * @param Driver        $driver
  * @param Configuration $config
  * @param EventManager  $eventManager
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!isset($params['defaultTableOptions'])) {
         $params['defaultTableOptions'] = [];
     }
     foreach (['engine', 'charset', 'collate'] as $name) {
         if (isset($params[$name])) {
             $params['defaultTableOptions'][$name] = $params[$name];
             unset($params[$name]);
         }
     }
     if (isset($params['prefix'])) {
         $this->prefix = $params['prefix'];
     }
     $this->regex = ['quotes' => "/([^'\"]+)(?:" . self::DOUBLE_QUOTED_TEXT . "|" . self::SINGLE_QUOTED_TEXT . ")?/As", 'placeholder' => "/" . preg_quote($this->placeholder) . "([a-zA-Z_][a-zA-Z0-9_]*)/"];
     parent::__construct($params, $driver, $config, $eventManager);
 }
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     $this->failoverStatus = new FailoverStatus($params);
     $this->heartbeat = new TableHeartbeat($params);
     parent::__construct($params, $driver, $config, $eventManager);
 }
예제 #9
0
 /**
  * @param array                         $params
  * @param \Doctrine\DBAL\Driver         $driver
  * @param \Doctrine\DBAL\Configuration  $config
  * @param \Doctrine\Common\EventManager $eventManager
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!isset($params['global']) || !isset($params['shards'])) {
         throw new \InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
     }
     if (!isset($params['shardChoser'])) {
         throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'");
     }
     if (is_string($params['shardChoser'])) {
         $params['shardChoser'] = new $params['shardChoser']();
     }
     if (!$params['shardChoser'] instanceof ShardChoser) {
         throw new \InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\\DBAL\\Sharding\\ShardChoser\\ShardChoser");
     }
     $this->connections[0] = array_merge($params, $params['global']);
     foreach ($params['shards'] as $shard) {
         if (!isset($shard['id'])) {
             throw new \InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id.");
         }
         if (!is_numeric($shard['id']) || $shard['id'] < 1) {
             throw new \InvalidArgumentException("Shard Id has to be a non-negative number.");
         }
         if (isset($this->connections[$shard['id']])) {
             throw new \InvalidArgumentException("Shard " . $shard['id'] . " is duplicated in the configuration.");
         }
         $this->connections[$shard['id']] = array_merge($params, $shard);
     }
     parent::__construct($params, $driver, $config, $eventManager);
 }
예제 #10
0
 public function __construct(array $params, $driver, $config = null, $eventManager = null)
 {
     parent::__construct($params, $driver, $config, $eventManager);
     $this->_platformMock = new DatabasePlatformMock();
     $this->_platform = $this->_platformMock;
 }
예제 #11
0
 public function __construct(array $params, Driver $driver, $config, $eventManager)
 {
     parent::__construct($params, $driver, $config, $eventManager);
 }
예제 #12
0
 private function connectToDatabase(Connection $db, $databaseName)
 {
     $db->close();
     $db->__construct(['dbname' => $databaseName] + $db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager());
     $db->connect();
 }
예제 #13
0
 /**
  * Initializes a new instance of the Connection class.
  *
  * @param array $params The connection parameters.
  * @param Driver $driver The driver to use.
  * @param Configuration|null $config The configuration, optional.
  * @param EventManager|null $em The event manager, optional.
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $em = null)
 {
     parent::__construct($params, $driver, $config, $em);
     $this->_expr = GeneralUtility::makeInstance(ExpressionBuilder::class, $this);
 }
예제 #14
0
 public function __construct($connection)
 {
     return parent::__construct($connection->getParams(), $connection->getDriver(), $connection->getConfiguration(), $connection->getEventManager());
 }
예제 #15
0
 /**
  * Initializes a new instance of the Connection class.
  *
  * This sets up necessary variables before calling parent constructor
  *
  * @param array         $params       Parameters for the driver
  * @param Driver        $driver       The driver to use
  * @param Configuration $config       The connection configuration
  * @param EventManager  $eventManager Event manager to use
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!defined('XOOPS_DB_PROXY') || $_SERVER['REQUEST_METHOD'] !== 'GET' || php_sapi_name() === 'cli') {
         self::setSafe(true);
     } else {
         self::setSafe(false);
     }
     self::setForce(false);
     self::$transactionActive = false;
     try {
         parent::__construct($params, $driver, $config, $eventManager);
     } catch (\Exception $e) {
         // We are dead in the water. This exception may contain very sensitive
         // information and cannot be allowed to be displayed as is.
         //$xoopsPreload->triggerEvent('core.exception', $e);
         trigger_error("Cannot get database connection", E_USER_ERROR);
     }
 }
 /**
  * Creates Master Slave Connection.
  *
  * @param array                              $params
  * @param \Doctrine\DBAL\Driver              $driver
  * @param \Doctrine\DBAL\Configuration|null  $config
  * @param \Doctrine\Common\EventManager|null $eventManager
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     if (!isset($params['slaves']) || !isset($params['master'])) {
         throw new \InvalidArgumentException('master or slaves configuration missing');
     }
     if (count($params['slaves']) == 0) {
         throw new \InvalidArgumentException('You have to configure at least one slaves.');
     }
     $params['master']['driver'] = $params['driver'];
     foreach ($params['slaves'] as $slaveKey => $slave) {
         $params['slaves'][$slaveKey]['driver'] = $params['driver'];
     }
     $this->keepSlave = isset($params['keepSlave']) ? (bool) $params['keepSlave'] : false;
     parent::__construct($params, $driver, $config, $eventManager);
 }
예제 #17
0
 /**
  * Initializes a new instance of the Connection class.
  *
  * @param array $params  The connection parameters.
  * @param Driver $driver
  * @param Configuration $config
  * @param EventManager $eventManager
  */
 public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
 {
     parent::__construct($params, $driver, $config, $eventManager);
     $this->_expr = new org_glizy_dataAccessDoctrine_Query_Expression_ExpressionBuilder($this);
 }