Create a single database connection instance.

@param  array $config
@return Connection
194801
protected function createSingleConnection($config)
    {
        $pdo = false;
        $connection = $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config);
        $connection->connect($config['host'], $config['username'], $config['password'], $config['database']);
        return $connection;
    }
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)
			)
		);
	}
675411
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection($config['connection'] ?? null),
            $config['table'],
            $config['queue'],
            $config['retry_after'] ?? 60
        );
    }
714786
public function connect(array $config)
    {
        $dsn = $this->getDsn($config);

        $options = $this->getOptions($config);

        // We need to grab the PDO options that should be used while making the brand
        // new connection instance. The PDO options control various aspects of the
        // connection's behavior, and some might be specified by the developers.
        $connection = $this->createConnection($dsn, $config, $options);

        if (! empty($config['database'])) {
            $connection->exec("use `{$config['database']}`;");
        }

        $this->configureEncoding($connection, $config);

        // Next, we will check to see if a timezone has been specified in this config
        // and if it has we will issue a statement to modify the timezone with the
        // database. Setting this DB timezone is an optional configuration item.
        $this->configureTimezone($connection, $config);

        $this->setModes($connection, $config);

        return $connection;
    }
430113
public static function make(array $config)
    {
        $builder = self::getBuilder();
        $configObject = $builder->build($config);
        $grid = new Grid($configObject);
        return $grid;
    }
671390
public static function createFromConfig(array $config)
    {
        $manager = static::createEmptyFromConfig($config);

        $manager->addCollection(new CssCollection)
                ->addCollection(new JavascriptCollection);

        return $manager;
       
    }
263048
public function connect(array $config){

		$defaults = array(
			'resource' => null,
			'persistent' => false,
			'charset' => 'utf8'
		);

		$config += $defaults;

		if(isset($config['string']))
			$string = $config['string'];
		else{
			// String generation
			$string = '';
			foreach(array('host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service') as $cfg){
				if(isset($config[$cfg]))
					$string .= "$cfg=$config[$cfg] ";
			}
		}

		// Connect
		if(is_resource($config['resource']))
			$connection = $config['resource'];
		elseif($config['persistent'])
			$connection = @pg_pconnect($string, PGSQL_CONNECT_FORCE_NEW);
		else
			$connection = @pg_connect($string, PGSQL_CONNECT_FORCE_NEW);

		if(!is_resource($connection))
			throw new DriverException("Connection to database failed.");

		$this->resource = $connection;

		// Encoding
		@pg_set_client_encoding($this->resource, $config['charset']);

		// Schema
		if(isset($config['schema']))
			$this->runQuery('SET search_path TO "' . $config['schema'] . '"');
	}
497921
protected function createPdo(array $config)
    {
        $dsn        = $this->getHostDsn($config);
        $userName   = (isset($config['username']) ? $config['username'] : null);
        $password   = (isset($config['password']) ? $config['password'] : null);
        $options    = $this->getPdoOptions($config);

        return new PDO($dsn, $userName, $password, $options);
    }
286101
public static function fromArray(array $config): EasyDB
    {

        /** @var string $dsn */
        $dsn      = $config[0];
        /** @var string|null $username */
        $username = $config[1] ?? null;
        /** @var string|null $password */
        $password = $config[2] ?? null;
        /** @var array $options */
        $options  = $config[3] ?? [];

        $dbEngine = '';
        $post_query = null;

        if (!\is_string($username)) {
            $username = '';
        }
        if (!\is_string($password)) {
            $password = '';
        }

        // Let's grab the DB engine
        if (strpos($dsn, ':') !== false) {
            $dbEngine = explode(':', $dsn)[0];
        }

        /** @var string $post_query */
        $post_query = '';

        // If no charset is specified, default to UTF-8
        switch ($dbEngine) {
            case 'mysql':
                if (\strpos($dsn, ';charset=') === false) {
                    $dsn .= ';charset=utf8mb4';
                }
                break;
            case 'pgsql':
                $post_query = "SET NAMES 'UNICODE'";
                break;
        }

        try {
            $pdo = new \PDO($dsn, $username, $password, $options);
        } catch (\PDOException $e) {
            if (\strpos((string) $e->getMessage(), 'could not find driver') !== false) {
                throw (new Issues\ConstructorFailed(
                    'Could not create a PDO connection. Is the driver installed/enabled?'
                ))->setRealException($e);
            }
            
            if (\strpos((string) $e->getMessage(), 'unknown database') !== false) {
                throw (new Issues\ConstructorFailed(
                    'Could not create a PDO connection. Check that your database exists.'
                ))->setRealException($e);
            }
            
            // Don't leak credentials directly if we can.
            throw (new Issues\ConstructorFailed(
                'Could not create a PDO connection. Please check your username and password.'
            ))->setRealException($e);
        }

        if (!empty($post_query)) {
            $pdo->query($post_query);
        }

        return new EasyDB($pdo, $dbEngine, $options);
    }
341189
public static function getDbInstance(Config $config) {
            $handle = self::getDbHandle($config);
            if (!isset(self::$pool[ $handle ])) {
                self::$pool[ $handle ] = new DB($config);
            }

            return self::$pool[ $handle ];
        }
937582
protected function makeConnection($name, array $config)
    {
        $timeout = isset($config['timeout']) ? $config['timeout'] : 10;

        $this->setOutput($connection = new Connection(

            $name, $config['host'], $config['username'], $this->getAuth($config), null, $timeout

        ));

        return $connection;
    }
919402
public static function factory($config = array())
    {
        $configuration = static::buildConfig($config);

        $client = new self($configuration->get('base_url'), $configuration);

        $client->addSubscriber(new KeyAuthPlugin($configuration->get('key')));

        static::loadDefinitions($client);
        static::toggleRateLimitingPlugin($client, $config);

        return $client;
    }
872965
public function connect(array $config)
    {
        // First we'll create the basic DSN and connection instance connecting to the
        // using the configuration option specified by the developer. We will also
        // set the default character set on the connections to UTF-8 by default.
        $connection = $this->createConnection(
            $this->getDsn($config), $config, $this->getOptions($config)
        );

        $this->configureEncoding($connection, $config);

        // Next, we will check to see if a timezone has been specified in this config
        // and if it has we will issue a statement to modify the timezone with the
        // database. Setting this DB timezone is an optional configuration item.
        $this->configureTimezone($connection, $config);

        $this->configureSchema($connection, $config);

        // Postgres allows an application_name to be set by the user and this name is
        // used to when monitoring the application with pg_stat_activity. So we'll
        // determine if the option has been specified and run a statement if so.
        $this->configureApplicationName($connection, $config);

        return $connection;
    }
358476
public static function instance($config = [])
    {
        if (null === self::$instance) {
            self::$instance = new static($config);
        }

        return self::$instance;
    }
1139179
public function connect(array $config){
		Connection::alias($config, 'database', 'file');
		Connection::alias($config, 'updateLimit', 'update_limit');

		$defaults = array(
			'memory' => false,
			'resource' => null,
			'updateLimit' => false,
			'charset' => 'UTF-8',
			'dbcharset' => 'UTF-8'
		);

		$config += $defaults;

		if($config['memory'])
			$config['database'] = ':memory:';

		// Connect
		if($config['resource'] instanceof SQLite3)
			$connection = $config['resource'];
		elseif(!isset($config['database']))
			throw new DriverException("No database file selected.");
		else{
			try{
				$connection = new SQLite3($config['database']);
			} catch(Exception $e){
				throw new DriverException($e->getMessage(), $e->getCode());
			}
		}

		if(!$connection instanceof SQLite3)
			throw new DriverException("Opening database file '$config[database]' failed.");

		$this->resource = $connection;
		$this->updateLimit = (bool) $config['updateLimit'];

		// Set charset
		$this->dbCharset = $config['dbcharset'];
		$this->charset = $config['charset'];
		if(strcasecmp($this->dbCharset, $this->charset) === 0)
			$this->dbCharset = $this->charset = null;
	}
438867
public function connect(Array $config)
    {
        $dsn = $this->getDSN($config);
        $options = $this->getOptions($config);

        $connection = $this->createConnection($dsn, $config, $options);

        if (isset($config['charset'])) {
            $connection->prepare("set names '" . $config['charset'] . "'")->execute();
        }

        if (isset($config['timezone'])) {
            $connection->prepare("set time zone '" . $config['timezone'] . "'")->execute();
        }

        return $connection;
    }
1044685
public function connect(array $config)
    {
        $options = $this->options($config);

        // SQLite provides supported for "in-memory" databases, which exist only for
        // lifetime of the request. These are mainly for tests.
        if ($config['database'] == ':memory:') {
            return new \Pimf\Database('sqlite::memory:', null, null, $options);
        }

        return new \Pimf\Database('sqlite:' . $config['database'], null, null, $options);
    }