Doctrine\DBAL\DBALException::driverRequired PHP Method

driverRequired() public static method

public static driverRequired ( string | null $url = null ) : DBALException
$url string | null The URL that was provided in the connection parameters (if any).
return DBALException
    public static function driverRequired($url = null)
    {
        if ($url) {
            return new self(sprintf("The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . "is given to DriverManager::getConnection(). Given URL: %s", $url));
        }
        return new self("The options 'driver' or 'driverClass' are mandatory if no PDO " . "instance is given to DriverManager::getConnection().");
    }

Usage Example

Esempio n. 1
0
 /**
  * Checks the list of parameters.
  *
  * @param array $params
  */
 private static function _checkParams(array $params)
 {
     // check existance of mandatory parameters
     // driver
     if (!isset($params['driver']) && !isset($params['driverClass'])) {
         throw DBALException::driverRequired();
     }
     // check validity of parameters
     // driver
     if (isset($params['driver']) && !isset(self::$_driverMap[$params['driver']])) {
         throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
     }
     if (isset($params['driverClass']) && !in_array('Doctrine\\DBAL\\Driver', class_implements($params['driverClass'], true))) {
         throw DBALException::invalidDriverClass($params['driverClass']);
     }
 }
All Usage Examples Of Doctrine\DBAL\DBALException::driverRequired