public static function getDriver(string $connectionString)
    {
        $connection = [
            'orig' => $connectionString,
            'type' => null,
            'user' => null,
            'pass' => null,
            'host' => null,
            'port' => null,
            'name' => null,
            'opts' => []
        ];
        $aliases = [
            'mysqli' => 'mysql',
            'pg' => 'postgre',
            'oci' => 'oracle',
            'firebird' => 'ibase'
        ];
        $connectionString = array_pad(explode('://', $connectionString, 2), 2, '');
        $connection['type'] = $connectionString[0];
        $connectionString = $connectionString[1];
        if (strpos($connectionString, '@') !== false) {
            $connectionString = array_pad(explode('@', $connectionString, 2), 2, '');
            list($connection['user'], $connection['pass']) = array_pad(explode(':', $connectionString[0], 2), 2, '');
            $connectionString = $connectionString[1];
        }
        $connectionString = array_pad(explode('/', $connectionString, 2), 2, '');
        list($connection['host'], $connection['port']) = array_pad(explode(':', $connectionString[0], 2), 2, null);
        $connectionString = $connectionString[1];
        if ($pos = strrpos($connectionString, '?')) {
            $opt = substr($connectionString, $pos + 1);
            parse_str($opt, $connection['opts']);
            if ($connection['opts'] && count($connection['opts'])) {
                $connectionString = substr($connectionString, 0, $pos);
            } else {
                $connection['opts'] = [];
            }
        }
        $connection['name'] = $connectionString;
        $connection['type'] = isset($aliases[$connection['type']]) ?
            $aliases[$connection['type']] :
            $connection['type'];
        $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver';
        return new $tmp($connection);
    }
public static function getDriver(string $connectionString)
    {
        $connection = [
            'orig' => $connectionString,
            'type' => null,
            'user' => null,
            'pass' => null,
            'host' => null,
            'port' => null,
            'name' => null,
            'opts' => []
        ];
        $aliases = [
            'mysqli' => 'mysql',
            'pg' => 'postgre',
            'oci' => 'oracle',
            'firebird' => 'ibase'
        ];
        $connectionString = array_pad(explode('://', $connectionString, 2), 2, '');
        $connection['type'] = $connectionString[0];
        $connectionString = $connectionString[1];
        if (strpos($connectionString, '@') !== false) {
            $connectionString = array_pad(explode('@', $connectionString, 2), 2, '');
            list($connection['user'], $connection['pass']) = array_pad(explode(':', $connectionString[0], 2), 2, '');
            $connectionString = $connectionString[1];
        }
        $connectionString = array_pad(explode('/', $connectionString, 2), 2, '');
        list($connection['host'], $connection['port']) = array_pad(explode(':', $connectionString[0], 2), 2, null);
        $connectionString = $connectionString[1];
        if ($pos = strrpos($connectionString, '?')) {
            $opt = substr($connectionString, $pos + 1);
            parse_str($opt, $connection['opts']);
            if ($connection['opts'] && count($connection['opts'])) {
                $connectionString = substr($connectionString, 0, $pos);
            } else {
                $connection['opts'] = [];
            }
        }
        $connection['name'] = $connectionString;
        $connection['type'] = isset($aliases[$connection['type']]) ?
            $aliases[$connection['type']] :
            $connection['type'];
        $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver';
        return new $tmp($connection);
    }
public static function getDriver ( string $ connectionString ) { $ connection = [ 'orig' => $ connectionString , 'type' => null , 'user' => null , 'pass' => null , 'host' => null , 'port' => null , 'name' => null , 'opts' => [ ] ] ; $ aliases = [ 'mysqli' => 'mysql' , 'pg' => 'postgre' , 'oci' => 'oracle' , 'firebird' => 'ibase' ] ; $ connectionString = array_pad ( explode ( '://' , $ connectionString , 2 ) , 2 , '' ) ; $ connection [ 'type' ] = $ connectionString [ 0 ] ; $ connectionString = $ connectionString [ 1 ] ; if ( strpos ( $ connectionString , '@' ) !== false ) { $ connectionString = array_pad ( explode ( '@' , $ connectionString , 2 ) , 2 , '' ) ; list ( $ connection [ 'user' ] , $ connection [ 'pass' ] ) = array_pad ( explode ( ':' , $ connectionString [ 0 ] , 2 ) , 2 , '' ) ; $ connectionString = $ connectionString [ 1 ] ; } $ connectionString = array_pad ( explode ( '/' , $ connectionString , 2 ) , 2 , '' ) ; list ( $ connection [ 'host' ] , $ connection [ 'port' ] ) = array_pad ( explode ( ':' , $ connectionString [ 0 ] , 2 ) , 2 , null ) ; $ connectionString = $ connectionString [ 1 ] ; if ( $ pos = strrpos ( $ connectionString , '?' ) ) { $ opt = substr ( $ connectionString , $ pos + 1 ) ; parse_str ( $ opt , $ connection [ 'opts' ] ) ; if ( $ connection [ 'opts' ] && count ( $ connection [ 'opts' ] ) ) { $ connectionString = substr ( $ connectionString , 0 , $ pos ) ; } else { $ connection [ 'opts' ] = [ ] ; } } $ connection [ 'name' ] = $ connectionString ; $ connection [ 'type' ] = isset ( $ aliases [ $ connection [ 'type' ] ] ) ? $ aliases [ $ connection [ 'type' ] ] : $ connection [ 'type' ] ; $ tmp = '\\vakata\\database\\driver\\' . strtolower ( $ connection [ 'type' ] ) . '\\Driver' ; return new $ tmp ( $ connection ) ; }
Create a driver instance from a connection string
@param string $connectionString the connection string
@return DriverInterface
Create a driver instance from a connection string