Creates connection to database.
@param array $config Configuration options
@throws DriverException
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'];
	}
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);
    }
1207556
public function connect(array $config): PDO
    {
        if (isset($config['options']) === false) {
            $config['options'] = [];
        }

        return $this->doConnect($config);
    }
161929
protected function createConnection( $driver, $connection, $database, $prefix = '', array $config = [] )
	{
		switch ( $driver )
		{
			case 'mysql':
				return new MySqlConnection( $connection, $database, $prefix, $config );
			case 'pgsql':
				return new PostgresConnection( $connection, $database, $prefix, $config );
			case 'sqlite':
				return new SQLiteConnection( $connection, $database, $prefix, $config );
			case 'sqlsrv':
				return new SqlServerConnection( $connection, $database, $prefix, $config );
		}

		throw new InvalidArgumentException( "Unsupported driver [$driver]" );
	}
226878
private function connect($config) {
		try {
			$this->pdoObject = new \PDO(
					$config["type"].':host=' . $config["serverName"] . ';dbname='
					. $config["dbName"] . ';port=' . $config["port"],
					$config["user"], $config["password"]);
			$this->pdoObject->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			$this->pdoObject->exec("SET CHARACTER SET utf8");

		} catch (\PDOException $e) {
			print "Error!: " . $e->getMessage() . "<br/>";
		}
	}
555485
public static function startDatabase(&$config) {
		$db = $config ['database'] ?? [ ];
		if ($db ['dbName'] !== '') {
			self::connect ( $db ['type'], $db ['dbName'], $db ['serverName'] ?? '127.0.0.1', $db ['port'] ?? 3306, $db ['user'] ?? 'root', $db ['password'] ?? '', $db ['options'] ?? [ ], $db ['cache'] ?? false);
		}
	}
448342
protected function _connection(array $config)
    {
        $redis = new \Redis;
        $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host'];
        $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port'];
        $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout'];
        $connect = empty($config['persistent']) ? 'connect' : 'pconnect';
        $redis->$connect($host, $port, $timeout);
        return $redis;
    }
992142
protected function createDatabaseDriver(array $config)
    {
        return new DatabaseRepository(
            $this->app['db']->connection(Arr::get($config, 'connection')),
            Arr::get($config, 'table')
        );
    }
1049412
public function addConnection(array $config, $name = 'default')
	{
		$connections = $this->prop['database.connections'];
		$connections[$name] = $config;
		$this->prop['database.connections'] = $connections;
	}
546741
public function connect(array $config)
	{
		$sqsConfig = array_only($config, array('key', 'secret', 'region', 'default_cache_config'));

		$sqs = SqsClient::factory($sqsConfig);

		return new SqsQueue($sqs, $config['queue']);
	}
599020
public function connect($config = array())
    {
        if (empty($this->mongo)) {
            $options = array();
            if (!empty($config['options'])) {
                $options = $config['options'];
            }
            $this->mongo = new \MongoClient($config['dsn'], $options);

        }
    }
412620
final protected function open_db_connection(array $config){

        $dns = 'mysql:host=' . $config['host'] . ';dbname=' . $config['database_name'];

        $this->database_connection = new \PDO($dns, $config['username'], $config['password']
        );

        $this->database_connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        $this->database_connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);

        return $this->database_connection;
    }
375940
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
    {
        if ($this->container->bound($key = "db.connection.{$driver}")) {
            return $this->container->make($key, [$connection, $database, $prefix, $config]);
        }

        switch ($driver) {
            case 'mysql':
                return new MySqlConnection($connection, $database, $prefix, $config);

            case 'pgsql':
                return new PostgresConnection($connection, $database, $prefix, $config);
        }

        return parent::createConnection($driver, $connection, $database, $prefix, $config);
    }
240633
public function connect(array $config)
    {
        $dsn = $this->getDsn($config);

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

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

        //
        $collation = $config['collation'];

        $charset = $config['charset'];

        $names = "set names '$charset'".
            (! is_null($collation) ? " collate '$collation'" : '');

        $connection->prepare($names)->execute();

        if (isset($config['strict']) && $config['strict']) {
            $connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute();
        }

        return $connection;
    }
500195
public static function setConfig(array $config)
    {
        if ( ! isset($config['connection'])) {
            throw new DbException('can`t find `connection` parameter in database config');
        }
        $connection = &$config['connection'];
        if ( ! isset($connection['default'])) {
            throw new DbException('can`t find `default` parameter in database config');
        }
        $default = &$connection['default'];
        if ( ! is_string($default) || empty($connection[$default])) {
            throw new DbException('parameter `default` must be string and contain contains name of default connection. So given section `' .
                $default .
                '` must present in database config');
        }

        return self::$config = $config;
    }
865711
public function connect(array $config)
    {
        $auth = $this->getAuth($config);
        $client = $this->getClient($auth);

        return $this->getAdapter($client);
    }
993585
public function connect($config)
    {
        $this->connection = Db::connect($config);
        $this->setBuilder();
        $this->prefix = $this->connection->getConfig('prefix');
        return $this;
    }