Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / lib / Doctrine / DBAL / DBALException.php
1 <?php
2
3 namespace Doctrine\DBAL;
4
5 class DBALException extends \Exception
6 {
7     public static function notSupported($method)
8     {
9         return new self("Operation '$method' is not supported by platform.");
10     }
11
12     public static function invalidPlatformSpecified()
13     {
14         return new self(
15             "Invalid 'platform' option specified, need to give an instance of ".
16             "\Doctrine\DBAL\Platforms\AbstractPlatform.");
17     }
18
19     public static function invalidPdoInstance()
20     {
21         return new self(
22             "The 'pdo' option was used in DriverManager::getConnection() but no ".
23             "instance of PDO was given."
24         );
25     }
26
27     public static function driverRequired()
28     {
29         return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ".
30             "instance is given to DriverManager::getConnection().");
31     }
32
33     public static function unknownDriver($unknownDriverName, array $knownDrivers)
34     {
35         return new self("The given 'driver' ".$unknownDriverName." is unknown, ".
36             "Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers));
37     }
38
39     public static function driverExceptionDuringQuery(\Exception $driverEx, $sql, array $params = array())
40     {
41         $msg = "An exception occurred while executing '".$sql."'";
42         if ($params) {
43             $msg .= " with params ".json_encode($params);
44         }
45         $msg .= ":\n\n".$driverEx->getMessage();
46
47         return new self($msg, 0, $driverEx);
48     }
49
50     public static function invalidWrapperClass($wrapperClass)
51     {
52         return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ".
53             "subtype of \Doctrine\DBAL\Connection.");
54     }
55
56     public static function invalidDriverClass($driverClass)
57     {
58         return new self("The given 'driverClass' ".$driverClass." has to implement the ".
59             "\Doctrine\DBAL\Driver interface.");
60     }
61
62     /**
63      * @param string $tableName
64      * @return DBALException
65      */
66     public static function invalidTableName($tableName)
67     {
68         return new self("Invalid table name specified: ".$tableName);
69     }
70
71     /**
72      * @param string $tableName
73      * @return DBALException
74      */
75     public static function noColumnsSpecifiedForTable($tableName)
76     {
77         return new self("No columns specified for table ".$tableName);
78     }
79
80     public static function limitOffsetInvalid()
81     {
82         return new self("Invalid Offset in Limit Query, it has to be larger or equal to 0.");
83     }
84
85     public static function typeExists($name)
86     {
87         return new self('Type '.$name.' already exists.');
88     }
89
90     public static function unknownColumnType($name)
91     {
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.'
99         );
100     }
101
102     public static function typeNotFound($name)
103     {
104         return new self('Type to be overwritten '.$name.' does not exist.');
105     }
106 }