本文整理汇总了PHP中Doctrine\DBAL\Connection::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::__construct方法的具体用法?PHP Connection::__construct怎么用?PHP Connection::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @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;
}
示例2: __construct
/**
* @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);
}
示例3: __construct
/**
* @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);
}
示例4: __construct
/**
* 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_]*)/";
}
示例5: __construct
/**
* @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: __construct
/**
* 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: __construct
/**
* 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);
}
示例8: __construct
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: __construct
/**
* @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: __construct
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: __construct
public function __construct(array $params, Driver $driver, $config, $eventManager)
{
parent::__construct($params, $driver, $config, $eventManager);
}
示例12: connectToDatabase
private function connectToDatabase(Connection $db, $databaseName)
{
$db->close();
$db->__construct(['dbname' => $databaseName] + $db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager());
$db->connect();
}
示例13: __construct
public function __construct($connection)
{
return parent::__construct($connection->getParams(), $connection->getDriver(), $connection->getConfiguration(), $connection->getEventManager());
}
示例14: __construct
/**
* 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);
}
}
示例15: __construct
/**
* 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);
}