public static function create(array $parameters, Configuration $configuration = null)
    {
        if (isset($parameters['driver_class'])) {
            if (!in_array('Fridge\DBAL\Driver\DriverInterface', class_implements($parameters['driver_class']))) {
                throw FactoryException::driverMustImplementDriverInterface($parameters['driver_class']);
            }

            $driverClass = $parameters['driver_class'];
        } elseif (isset($parameters['driver'])) {
            if (!isset(self::$mappedDriverClasses[$parameters['driver']])) {
                throw FactoryException::driverDoesNotExist($parameters['driver'], self::getAvailableDrivers());
            }

            $driverClass = self::$mappedDriverClasses[$parameters['driver']];
        } else {
            throw FactoryException::driverRequired(self::getAvailableDrivers());
        }

        if (isset($parameters['connection_class'])) {
            if (!in_array(
                'Fridge\DBAL\Connection\ConnectionInterface',
                class_implements($parameters['connection_class'])
            )) {
                throw FactoryException::connectionMustImplementConnectionInterface($parameters['connection_class']);
            }

            $connectionClass = $parameters['connection_class'];
        } else {
            $connectionClass = 'Fridge\DBAL\Connection\Connection';
        }

        return new $connectionClass($parameters, new $driverClass(), $configuration);
    }
public static function create(array $parameters, Configuration $configuration = null)
    {
        if (isset($parameters['driver_class'])) {
            if (!in_array('Fridge\DBAL\Driver\DriverInterface', class_implements($parameters['driver_class']))) {
                throw FactoryException::driverMustImplementDriverInterface($parameters['driver_class']);
            }

            $driverClass = $parameters['driver_class'];
        } elseif (isset($parameters['driver'])) {
            if (!isset(self::$mappedDriverClasses[$parameters['driver']])) {
                throw FactoryException::driverDoesNotExist($parameters['driver'], self::getAvailableDrivers());
            }

            $driverClass = self::$mappedDriverClasses[$parameters['driver']];
        } else {
            throw FactoryException::driverRequired(self::getAvailableDrivers());
        }

        if (isset($parameters['connection_class'])) {
            if (!in_array(
                'Fridge\DBAL\Connection\ConnectionInterface',
                class_implements($parameters['connection_class'])
            )) {
                throw FactoryException::connectionMustImplementConnectionInterface($parameters['connection_class']);
            }

            $connectionClass = $parameters['connection_class'];
        } else {
            $connectionClass = 'Fridge\DBAL\Connection\Connection';
        }

        return new $connectionClass($parameters, new $driverClass(), $configuration);
    }
public static function create ( array $ parameters , Configuration $ configuration = null ) { if ( isset ( $ parameters [ 'driver_class' ] ) ) { if ( ! in_array ( 'Fridge\DBAL\Driver\DriverInterface' , class_implements ( $ parameters [ 'driver_class' ] ) ) ) { throw FactoryException :: driverMustImplementDriverInterface ( $ parameters [ 'driver_class' ] ) ; } $ driverClass = $ parameters [ 'driver_class' ] ; } elseif ( isset ( $ parameters [ 'driver' ] ) ) { if ( ! isset ( self :: $ mappedDriverClasses [ $ parameters [ 'driver' ] ] ) ) { throw FactoryException :: driverDoesNotExist ( $ parameters [ 'driver' ] , self :: getAvailableDrivers ( ) ) ; } $ driverClass = self :: $ mappedDriverClasses [ $ parameters [ 'driver' ] ] ; } else { throw FactoryException :: driverRequired ( self :: getAvailableDrivers ( ) ) ; } if ( isset ( $ parameters [ 'connection_class' ] ) ) { if ( ! in_array ( 'Fridge\DBAL\Connection\ConnectionInterface' , class_implements ( $ parameters [ 'connection_class' ] ) ) ) { throw FactoryException :: connectionMustImplementConnectionInterface ( $ parameters [ 'connection_class' ] ) ; } $ connectionClass = $ parameters [ 'connection_class' ] ; } else { $ connectionClass = 'Fridge\DBAL\Connection\Connection' ; } return new $ connectionClass ( $ parameters , new $ driverClass ( ) , $ configuration ) ; }
Creates a DBAL connection.

$parameters must contain at least:
- driver (string) (ex: pdo_mysql, pdo_pgsql)
OR
- driver_class (string) (ex: Fridge\DBAL\Driver\MySQLDriver)

If you use driver & driver_class parameters simultaneously, the driver_class will be used.

$parameters can contain:
- connection_class (string) (ex: Fridge\DBAL\Connection\Connection)
- username (string)
- password (string)
- dbname (string)
- host (string)
- port (integer)

If you don't use the connection_class parameter, the class Fridge\DBAL\Connection\Connection will be used.

$parameters can contain some specific database parameters:
- pdo_mysql: unix_socket (string), charset (string), driver_options (array)
- pdo_pgsql: driver_options (array)
- mysqli: unix_socket (string), charset (string)

@param array                      $parameters    The connection parameters.
@param \Fridge\DBAL\Configuration $configuration The connection configuration.

@throws \Fridge\DBAL\Exception\FactoryException If there is no driver, it the driver does not exist, if the
driver class does not implement the DriverInterface or if the
connection class does not implement the ConnectionInterface

@return \Fridge\DBAL\Connection\ConnectionInterface The DBAL Connection.
Creates a DBAL connection .