atk4\data\Persistence::connect PHP Method

connect() public static method

Connects database.
public static connect ( string $dsn, string $user = null, string $password = null, array $args = [] ) : Persistence
$dsn string
$user string
$password string
$args array
return Persistence
    public static function connect($dsn, $user = null, $password = null, $args = [])
    {
        if (strpos($dsn, ':') === false) {
            throw new Exception(["Your DSN format is invalid. Must be in 'driver:host:options' format", 'dsn' => $dsn]);
        }
        $driver = explode(':', $dsn, 2)[0];
        switch (strtolower(isset($args['driver']) ?: $driver)) {
            case 'mysql':
            case 'dumper':
            case 'counter':
            case 'sqlite':
                return new Persistence_SQL($dsn, $user, $password, $args);
            default:
                throw new Exception(['Unable to determine persistence driver from DSN', 'dsn' => $dsn]);
        }
    }