Create a single database connection instance.

@param  array  $config
@return \Illuminate\Database\Connection
510034
protected function createReadWriteConnection(array $config)
    {
        $connection = $this->createSingleConnection($this->getWriteConfig($config));

        return $connection->setReadPdo($this->createReadPdo($config));
    }
359844
public function configure($config = [])
    {
        $redisConfig = config('database.redis.' . $config['connection']);

        $this->config = [
            'host'     => $redisConfig['host'],
            'port'     => $redisConfig['port'],
            'database' => $redisConfig['database']
        ];

        return $this;
    }
1368858
public function createCommand($config = [])
    {
        $this->open();
        $config['db'] = $this;
        $command = new Command($config);

        return $command;
    }
1291547
public function connect(array $config)
    {
        $options = $this->getOptions($config);

        return $this->createConnection($this->getDsn($config), $config, $options);
    }
902227
public function createConnector( array $config )
	{
		if ( !isset( $config['driver'] ) )
			throw new InvalidArgumentException( 'A driver must be specified.' );

		switch ( $config['driver'] )
		{
			case 'mysql':
				return new MySqlConnector;
			case 'pgsql':
				return new PostgresConnector;
			case 'sqlite':
				return new SQLiteConnector;
			case 'sqlsrv':
				return new SqlServerConnector;
		}

		throw new InvalidArgumentException( "Unsupported driver [{$config['driver']}]" );
	}
1207556
public function connect(array $config): PDO
    {
        if (isset($config['options']) === false) {
            $config['options'] = [];
        }

        return $this->doConnect($config);
    }
421030
public function connect(array $config){

		// Defaults
		$defaults = array(
			'resource' => null,
			'charset' => 'utf8',
			'username' => ini_get('mysqli.default_user'),
			'password' => ini_get('mysqli.default_pw'),
			'database' => '',
			'socket' => ini_get('mysqli.default_socket'),
			'port' => ini_get('mysqli.default_port'),
			'host' => ini_get('mysqli.default_host'),
			'persistent' => false,
			'unbuffered' => false
		);

		$config += $defaults;

		// Connect
		if($config['resource'] instanceof mysqli)
			$this->resource = $config['resource'];
		else
			$this->resource = new mysqli($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket']);

		if($this->resource->connect_errno)
			throw new DriverException($this->resource->connect_error, $this->resource->connect_errno);

		// Set charset
		if($this->resource instanceof mysqli){
			$ok = @$this->resource->set_charset($config['charset']);
			if(!$ok)
				$this->runQuery("SET NAMES " . $config['charset']);
		}

		$this->unbuffered = $config['unbuffered'];
	}
311523
protected function createTokenRepository(array $config)
    {
        return new DatabaseTokenRepository(
            $this->app['db']->connection(),
            $config['table'],
            $this->app['config']['app.key'],
            $config['expire']
        );
    }
562757
private function createConnection($config): Connection
    {
        if (is_string($config)) {
            $config = ['url' => $config];
        }

        return DriverManager::getConnection($config, $this->configuration, $this->eventManager);
    }
865711
public function connect(array $config)
    {
        $auth = $this->getAuth($config);
        $client = $this->getClient($auth);

        return $this->getAdapter($client);
    }
776404
public static function create($id, array $config)
    {
        static::$databaseConnections[$id] = static::createDatabaseConnection($config);

        if (static::$activeDatabaseConnection === null) {
            static::select($id);
        }
    }
1234771
public function doConnect($config)
    {
        $connectionString = 'sqlite:' . $config['database'];
        return $this->container->build(
            '\PDO',
            array($connectionString, null, null, $config['options'])
        );
    }
466372
protected function createPdoResolverWithHosts( array $config )
	{
		return function () use ( $config ) {

			foreach( Arr::shuffle( $hosts = $this->parseHosts( $config ) ) as $key => $host )
			{
				$config['host'] = $host;
				try
				{
					return $this->createConnector( $config )->connect( $config );
				}
				catch( PDOException $e )
				{
					if( count( $hosts ) - 1 === $key )
					{
						App::Log($e);
					}
				}
			}

			if(!isset($e)) {
				$e = new PDOException("Empty connection");
			}

			throw $e;
		};
	}
791166
protected function createDatabaseDriver( array $config )
	{
		return new DatabaseStore( DatabaseManager::i()->connection( Arr::get( $config, 'connection' ) ), Encrypter::i(), $config['table'], $this->getPrefix( $config ) );
	}
519252
public function connect(array $config)
    {
        $options = $this->getOptions($config);

        if ($config['database'] == ':memory:') {
            return $this->createConnection('sqlite::memory:', $config, $options);
        }

        $path = realpath($config['database']);

        if ($path === false) {
            throw new \InvalidArgumentException("Database does not exist.");
        }

        return $this->createConnection("sqlite:{$path}", $config, $options);
    }
784003
public function createConnector(array $config)
    {
        if (! isset($config['driver'])) {
            throw new \InvalidArgumentException("A driver must be specified.");
        }

        if ($this->container->bound($key = "db.connector.{$config['driver']}")) {
            return $this->container->make($key);
        }

        switch ($config['driver'])
        {
            case 'mysql':
                return new MySqlConnector;

            case 'pgsql':
                return new PostgresConnector;

            case 'sqlite':
                return new SQLiteConnector;

            case 'sqlsrv':
                return new SqlServerConnector;
        }

        throw new \InvalidArgumentException("Unsupported driver [{$config['driver']}]");
    }
619016
protected function createDatabaseDriver(array $config)
	{
		$connection = $this->app['db']->connection(array_get($config, 'connection'));

		return $this->repository(
			new DatabaseStore(
				$connection, $this->app['encrypter'], $config['table'], $this->getPrefix($config)
			)
		);
	}