Establishes a connection to the database server

@param string $dsn A Driver-specific PDO-DSN
@param array $config configuration to be used for creating connection
@return bool true on success
12581
protected function _connect($dsn, array $config)
    {
        $connection = new Oci8(
            $dsn,
            $config['username'],
            $config['password'],
            $config['flags']
        );
        $this->connection($connection);
        return true;
    }
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/>";
		}
	}
562757
private function createConnection($config): Connection
    {
        if (is_string($config)) {
            $config = ['url' => $config];
        }

        return DriverManager::getConnection($config, $this->configuration, $this->eventManager);
    }
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;
    }
69656
public function createConnection($dsn, array $config, array $options)
    {
        $username = Arr::get($config, 'username');
        $password = Arr::get($config, 'password');

        try {
            $pdo = new PDO($dsn, $username, $password, $options);
        } catch (Exception $e) {
            $pdo = $this->tryAgainIfCausedByLostConnection(
                $e, $dsn, $username, $password, $options
            );
        }

        return $pdo;
    }
239498
public function createConnection($tns, array $config, array $options)
    {
        // add fallback in case driver is not set, will use pdo instead
        if (! in_array($config['driver'], ['oci8', 'pdo-via-oci8', 'oracle'])) {
            return parent::createConnection($tns, $config, $options);
        }

        $config             = $this->setCharset($config);
        $options['charset'] = $config['charset'];

        return new Oci8($tns, $config['username'], $config['password'], $options);
    }
235845
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',
			'persistent' => false,
			'unbuffered' => false
		);

		$config += $defaults;

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

		// Connect
		if(is_resource($config['resource']))
			$connection = $config['resource'];
		elseif(!isset($config['database']))
			throw new DriverException("No database file selected.");
		elseif($config['persistent'])
			$connection = @sqlite_popen($config['database'], 0666, $error);
		else
			$connection = @sqlite_open($config['database'], 0666, $error);

		if(!is_resource($connection))
			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;

		$this->unbuffered = $config['unbuffered'];
		$this->persistent = $config['persistent'];
	}
920921
protected function dsn_connect($dsn, $mode)
    {
        $this->db_error     = false;
        $this->db_error_msg = null;

        // return existing handle
        if ($this->dbhs[$mode]) {
            $this->dbh = $this->dbhs[$mode];
            $this->db_mode = $mode;
            return $this->dbh;
        }

        // connect to database
        if ($dbh = $this->conn_create($dsn)) {
            $this->dbh          = $dbh;
            $this->dbhs[$mode]  = $dbh;
            $this->db_mode      = $mode;
            $this->db_connected = true;
        }
    }
1247607
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection(array_get($config, 'connection')),
            array_get($config, 'table', 'queues'),
            array_get($config, 'queue', null),
            array_get($config, 'expire', 60),
            array_get($config, 'lock_type', 60)
        );
    }
948537
public function connect($debug = false)
    {
        if (isset($this->options['dsn'])) {
            if ($this->options['verbose']) {
                echo "<p>Connecting to dsn:<br><code>" . $this->options['dsn'] . "</code>";
            }

            try {
                $this->db = new \PDO(
                    $this->options['dsn'],
                    $this->options['username'],
                    $this->options['password'],
                    $this->options['driver_options']
                );

                $this->db->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, $this->options['fetch_mode']);
                $this->db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);

            } catch(\Exception $e) {

                if ($debug || $this->options['debug_connect']) {
                    // For debug purpose, shows all connection details
                    throw $e;
                } else {
                    // Hide connection details.
                    throw new \PDOException("Could not connect to database, hiding connection details. Connect using 'debug' to see the full exception message.");
                }
            }

        } else {
            throw new \Exception("You can not connect, missing dsn.");
        }

        $this->loadHistory();
    }
848823
public function connect($config)
    {
        $this->connection = Db::connect($config);
        $this->setBuilder();
        return $this;
    }
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']}]" );
	}
83517
protected function getHostDsn(array $config)
    {
        if (!isset($config['host'])) {
            throw new DbException("Db connection host can not be empty.");
        }

        if (!isset($config['database'])) {
            throw new DbException("Db connection database can not be empty.");
        }

        $charset    = "";
        if (null != $this->config['charset']) {
            $charset = ";charset={$this->config['charset']}";
        }

        if (isset($config['port'])) {
            return "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}" . $charset;
        }

        return "mysql:host={$config['host']};dbname={$config['database']}" . $charset;
    }
442700
private function connect($dsn, $username, $password, array $options, $charset)
    {
        $sessionMode = array_key_exists('session_mode', $options) ? $options['session_mode'] : null;

        if (array_key_exists(PDO::ATTR_PERSISTENT, $options) && $options[PDO::ATTR_PERSISTENT]) {
            $this->dbh = @oci_pconnect($username, $password, $dsn, $charset, $sessionMode);
        } else {
            $this->dbh = @oci_connect($username, $password, $dsn, $charset, $sessionMode);
        }

        if (! $this->dbh) {
            $e = oci_error();
            throw new Oci8Exception($e['message']);
        }
    }
1051558
private function getDsn(array $config)
    {
        $host = isset($config['host']) ? "host={$config['host']};" : '';
        $dsn  = "pgsql:{$host}dbname={$config['database']}";

        if (isset($config['port'])) {
            $dsn .= ";port={$config['port']}";
        }
        if (isset($config['sslmode'])) {
            $dsn .= ";sslmode={$config['sslmode']}";
        }
        if (isset($config['sslcert'])) {
            $dsn .= ";sslcert={$config['sslcert']}";
        }
        if (isset($config['sslkey'])) {
            $dsn .= ";sslkey={$config['sslkey']}";
        }
        if (isset($config['sslrootcert'])) {
            $dsn .= ";sslrootcert={$config['sslrootcert']}";
        }

        return $dsn;
    }
934508
public function connect(array $config)
    {
        // This connection string format can also be used to connect
        // to Azure SQL Server databases.
        $port = (isset($config['port'])) ? ',' . $config['port'] : '';

        //check for dblib for mac users connecting to mssql
        if (isset($config['dsn_type']) && !empty($config['dsn_type']) && $config['dsn_type'] == 'dblib') {
            $dsn = "dblib:host={$config['host']}{$port};dbname={$config['database']}";
        } else {
            $dsn = "sqlsrv:Server={$config['host']}{$port};Database={$config['database']}";
        }

        return new \Pimf\Database($dsn, $config['username'], $config['password'], $this->options($config));
    }
146169
public function createConnection($dsn, array $config, array $options)
    {
        $username = array_get($config, 'username');

        $password = array_get($config, 'password');

        return new PDO($dsn, $username, $password, $options);
    }