3 namespace Doctrine\DBAL;
5 class DBALException extends \Exception
7 public static function notSupported($method)
9 return new self("Operation '$method' is not supported by platform.");
12 public static function invalidPlatformSpecified()
15 "Invalid 'platform' option specified, need to give an instance of ".
16 "\Doctrine\DBAL\Platforms\AbstractPlatform.");
19 public static function invalidPdoInstance()
22 "The 'pdo' option was used in DriverManager::getConnection() but no ".
23 "instance of PDO was given."
27 public static function driverRequired()
29 return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ".
30 "instance is given to DriverManager::getConnection().");
33 public static function unknownDriver($unknownDriverName, array $knownDrivers)
35 return new self("The given 'driver' ".$unknownDriverName." is unknown, ".
36 "Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers));
39 public static function driverExceptionDuringQuery(\Exception $driverEx, $sql, array $params = array())
41 $msg = "An exception occurred while executing '".$sql."'";
43 $msg .= " with params ".json_encode($params);
45 $msg .= ":\n\n".$driverEx->getMessage();
47 return new self($msg, 0, $driverEx);
50 public static function invalidWrapperClass($wrapperClass)
52 return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ".
53 "subtype of \Doctrine\DBAL\Connection.");
56 public static function invalidDriverClass($driverClass)
58 return new self("The given 'driverClass' ".$driverClass." has to implement the ".
59 "\Doctrine\DBAL\Driver interface.");
63 * @param string $tableName
64 * @return DBALException
66 public static function invalidTableName($tableName)
68 return new self("Invalid table name specified: ".$tableName);
72 * @param string $tableName
73 * @return DBALException
75 public static function noColumnsSpecifiedForTable($tableName)
77 return new self("No columns specified for table ".$tableName);
80 public static function limitOffsetInvalid()
82 return new self("Invalid Offset in Limit Query, it has to be larger or equal to 0.");
85 public static function typeExists($name)
87 return new self('Type '.$name.' already exists.');
90 public static function unknownColumnType($name)
92 return new self('Unknown column type "'.$name.'" requested. Any Doctrine type that you use has ' .
93 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' .
94 'known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If this error occurs during database ' .
95 'introspection then you might have forgot to register all database types for a Doctrine Type. Use ' .
96 'AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement ' .
97 'Type#getMappedDatabaseTypes(). If the type name is empty you might ' .
98 'have a problem with the cache or forgot some mapping information.'
102 public static function typeNotFound($name)
104 return new self('Type to be overwritten '.$name.' does not exist.');