Adds database connection to pool.

@param string $connectionName
@param \PDO $connection
@return void
436224
public function addConnection(string $connectionName, \PDO $connection): void
    {
        $this->connections[$connectionName] = $connection;
    }
622319
protected function setDatabaseConfiguration($connection, &$database, &$configs)
    {
        $configs = [];

        if( is_array($database) )
        {
            $configs  = $database;
            $database = $connection;
        }

        $configs['database'] = $database ?: $this->defaultDatabaseName;
    }
926175
public function provideConnection(string $connectionName = ''): \PDO
    {
        if (empty($connectionName)) {
            $connectionName = $this->defaultConnectionName;
        }
        if ($this->hasConnection($connectionName) === true) {
            return $this->getConnection($connectionName);
        }

        $dbConfig = $this->credentials[$connectionName];

        switch ($dbConfig['driver']) {
            case 'mysql':
                $adapter = new PdoMysql;
                break;
            default:
                throw new DatabaseException('Unsupported database driver. Check config.');
        }

        $connection = $adapter->connect($dbConfig);
        $this->addConnection($connectionName, $connection);

        return $connection;
    }
735075
public static function checkConnections($connection_name, $table, $check)
    {
        if($check === true)
        {
            $connections = DB::connection($connection_name)->table($table)->get();

            foreach($connections as $connection)
            {
                $name = $connection->name;

                try{
                    $testConnection = DB::connection($name)->getPdo();
                }catch(\Exception $e)
                {
                    $error = $e->getMessage();
                    \error_log($error);
                }
                if(!empty($testConnection) && empty($error))
                {
                    $update = DB::connection($connection_name)->table($table)->where('name', $name)->update(['status' => true]);
                }
                else
                {
                    $update = DB::connection($connection_name)->table($table)->where('name', $name)->update(['status' => false]);
                }
            }
        }
    }
556769
public function addConnection(string $name = null, Connection $connection = null): self
    {
        if (is_null($name)) {
            $this->defaultConnection = $connection;
        } else {
            $this->registry[$name] = $connection;
        }

        return $this;
    }
420054
private function saveMigration(Connection $connection, string $class): void
    {
        $format = $connection->getSchemaManager()->getDatabasePlatform()->getDateTimeFormatString();
        $now    = (new DateTimeImmutable())->format($format);
        $connection->insert(static::MIGRATIONS_TABLE, [
            static::MIGRATIONS_COLUMN_CLASS       => $class,
            static::MIGRATIONS_COLUMN_MIGRATED_AT => $now,
        ]);
    }
706152
public function setConnection($name, ConnectionInterface $connection)
    {
        $manager = new ConnectionManagerSingle();
        $manager->setConnection($connection);
        $this->setConnectionManager($name, $manager);
    }
1037938
public static function initialize(Connection $connection, string $baseNamespace = "\\")
    {
        self::$_connection    = $connection;
        self::$_baseNamespace = Str::trailing($baseNamespace, "\\");
    }
300602
public function findConnection(string $connectionName)
  {
    if ( empty($connectionName) ) {
      # Take first available connection
      $connection = reset($this->connections);
      if ($connection === false)
        return null;
    } else {
      # Attempt to find the connection from the pool
      $connection = ( $this->connections[strtolower($connectionName)] ?? null);
    }

    return $connection;
  }
465371
public function release( MW_DB_Connection_Interface $connection, $name = 'db' )
	{
		if( ( $connection instanceof MW_DB_Connection_PDO ) === false ) {
			throw new MW_DB_Exception( 'Connection object isn\'t of type PDO' );
		}

		$this->_connections[$name][] = $connection;
	}
680306
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $params = $connection->getParams();
        if (!isset($params['charset'])) {
            throw new RuntimeException("No connection charset specified");
        }
        $pdo->exec('SET NAMES ' . $pdo->quote($params['charset']));
    }
744636
public static function for_table($table_name, $connection_name = parent::DEFAULT_CONNECTION)
        {
            self::_setupDb($connection_name);

            return new self($table_name, [], $connection_name);
        }
253976
public function run(Connection $connection, $append = false)
    {
        if (!$append) {
            //in the future, resolve key constraints here
            foreach (array_unique($this->dropTables) as $table) {
                $connection->delete($table, [1 => 1], [\PDO::PARAM_INT]);
            }
        }

        foreach ($this->getSortedFixtures() as $fixture) {
            $this->runFixture($connection, $fixture);
        }
    }
902818
public function addConnection(TraceablePDO $pdo, $name = null)
    {
        if ($name === null) {
            $name = spl_object_hash($pdo);
        }
        $this->connections[$name] = $pdo;
    }
1364371
public function addConnection(Connection $connection, bool $useLogger = true)
    {
        if ($useLogger) {
            $connection->setLogger($this->getLogger());
        }
        $this->connections[$connection->getType()] = $connection;
        if ($connection->isDefault()) {
            $this->setDefaultConnectionByType($connection->getType());
        }
    }
283500
protected function loadDbalConnection($name, array $connection, ContainerBuilder $container)
    {
        $configuration = $container->setDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name), new ChildDefinition('doctrine.dbal.connection.configuration'));
        $logger        = null;
        if ($connection['logging']) {
            $logger = new Reference('doctrine.dbal.logger');
        }
        unset($connection['logging']);
        if ($connection['profiling']) {
            $profilingLoggerId = 'doctrine.dbal.logger.profiling.' . $name;
            $container->setDefinition($profilingLoggerId, new ChildDefinition('doctrine.dbal.logger.profiling'));
            $profilingLogger = new Reference($profilingLoggerId);
            $container->getDefinition('data_collector.doctrine')->addMethodCall('addLogger', [$name, $profilingLogger]);

            if ($logger !== null) {
                $chainLogger = new ChildDefinition('doctrine.dbal.logger.chain');
                $chainLogger->addMethodCall('addLogger', [$profilingLogger]);

                $loggerId = 'doctrine.dbal.logger.chain.' . $name;
                $container->setDefinition($loggerId, $chainLogger);
                $logger = new Reference($loggerId);
            } else {
                $logger = $profilingLogger;
            }
        }
        unset($connection['profiling']);

        if (isset($connection['auto_commit'])) {
            $configuration->addMethodCall('setAutoCommit', [$connection['auto_commit']]);
        }

        unset($connection['auto_commit']);

        if (isset($connection['schema_filter']) && $connection['schema_filter']) {
            if (method_exists(\Doctrine\DBAL\Configuration::class, 'setSchemaAssetsFilter')) {
                $definition = new Definition(RegexSchemaAssetFilter::class, [$connection['schema_filter']]);
                $definition->addTag('doctrine.dbal.schema_filter', ['connection' => $name]);
                $container->setDefinition(sprintf('doctrine.dbal.%s_regex_schema_filter', $name), $definition);
            } else {
                // backwards compatibility with dbal < 2.9
                $configuration->addMethodCall('setFilterSchemaAssetsExpression', [$connection['schema_filter']]);
            }
        }

        unset($connection['schema_filter']);

        if ($logger) {
            $configuration->addMethodCall('setSQLLogger', [$logger]);
        }

        // event manager
        $container->setDefinition(sprintf('doctrine.dbal.%s_connection.event_manager', $name), new ChildDefinition('doctrine.dbal.connection.event_manager'));

        // connection
        $options = $this->getConnectionOptions($connection);

        $def = $container
            ->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new ChildDefinition('doctrine.dbal.connection'))
            ->setPublic(true)
            ->setArguments([
                $options,
                new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)),
                new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)),
                $connection['mapping_types'],
            ]);

        // Set class in case "wrapper_class" option was used to assist IDEs
        if (isset($options['wrapperClass'])) {
            $def->setClass($options['wrapperClass']);
        }

        if (! empty($connection['use_savepoints'])) {
            $def->addMethodCall('setNestTransactionsWithSavepoints', [$connection['use_savepoints']]);
        }

        // Create a shard_manager for this connection
        if (! isset($options['shards'])) {
            return;
        }

        $shardManagerDefinition = new Definition($options['shardManagerClass'], [new Reference(sprintf('doctrine.dbal.%s_connection', $name))]);
        $container->setDefinition(sprintf('doctrine.dbal.%s_shard_manager', $name), $shardManagerDefinition);
    }
1079247
protected function connect(string $connectionName): Connection
	{
		if(!isset($this->configurations[$connectionName]))
		{
			throw new RuntimeException(vsprintf('[ %s ] has not been defined in the database configuration.', [$connectionName]));
		}

		$config = $this->configurations[$connectionName];

		$driver = $this->normalizeDriverName(explode(':', $config['dsn'], 2)[0]);

		$compiler = $this->getQueryCompilerClass($driver);

		$helper = $this->getQueryBuilderHelperClass($driver);

		$connection = $this->getConnectionClass($driver);

		return new $connection($connectionName, $compiler, $helper, $config);
	}