src/Arvici/Heart/Database/Driver/MySQL/Driver.php
public function connect(array $config, $username = null, $password = null, array $options = array())
    {
        // Validate config
        if (! isset($config['host'], $config['database'])) {
            throw new DatabaseDriverException("No 'host' or 'database' given in the configuration of the connection!");
        }

        $port = isset($config['port']) ? $config['port'] : 3306;
        $charset = isset($config['charset']) ? $config['charset'] : 'utf8';

        // Prepare dsn.
        $dsn = "mysql:host={$config['host']};port=$port;dbname={$config['database']};charset=$charset";

        // Connect
        $connection = new Connection($dsn, $username, $password, $options);

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

        return $connection;
    }
public function connect(array $config, $username = null, $password = null, array $options = array())
    {
        // Validate config
        if (! isset($config['host'], $config['database'])) {
            throw new DatabaseDriverException("No 'host' or 'database' given in the configuration of the connection!");
        }

        $port = isset($config['port']) ? $config['port'] : 3306;
        $charset = isset($config['charset']) ? $config['charset'] : 'utf8';

        // Prepare dsn.
        $dsn = "mysql:host={$config['host']};port=$port;dbname={$config['database']};charset=$charset";

        // Connect
        $connection = new Connection($dsn, $username, $password, $options);

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

        return $connection;
    }
public function connect ( array $ config , $ username = null , $ password = null , array $ options = array ( ) ) { // Validate config if ( ! isset ( $ config [ 'host' ] , $ config [ 'database' ] ) ) { throw new DatabaseDriverException ( "No 'host' or 'database' given in the configuration of the connection!" ) ; } $ port = isset ( $ config [ 'port' ] ) ? $ config [ 'port' ] : 3306 ; $ charset = isset ( $ config [ 'charset' ] ) ? $ config [ 'charset' ] : 'utf8' ; // Prepare dsn. $ dsn = "mysql:host={$config['host']};port=$port;dbname={$config['database']};charset=$charset" ; // Connect $ connection = new Connection ( $ dsn , $ username , $ password , $ options ) ; $ connection -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; return $ connection ; }
Create the connection. Will return a connection instance.

@param array $config Specific configuration for the driver to establish connection and maintain it.
@param string|null $username Username to connect, could be optional. Driver specific.
@param string|null $password Password to connect, could be optional. Driver specific.
@param array $options Driver options apply to the connection and driver itself.

@return \Arvici\Heart\Database\Connection

@throws DatabaseDriverException
Create the connection . Will return a connection instance .