Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Query / QueryException.php
1 <?php
2 /*
3  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * This software consists of voluntary contributions made by many individuals
16  * and is licensed under the MIT license. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 namespace Doctrine\ORM\Query;
21
22 use Doctrine\ORM\Query\AST\PathExpression;
23
24 /**
25  * Description of QueryException
26  *
27  * 
28  * @link    www.doctrine-project.org
29  * @since   2.0
30  * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
31  * @author  Jonathan Wage <jonwage@gmail.com>
32  * @author  Roman Borschel <roman@code-factory.org>
33  * @author  Benjamin Eberlei <kontakt@beberlei.de>
34  */
35 class QueryException extends \Doctrine\ORM\ORMException
36 {
37     public static function dqlError($dql)
38     {
39         return new self($dql);
40     }
41
42     public static function syntaxError($message, $previous = null)
43     {
44         return new self('[Syntax Error] ' . $message, 0, $previous);
45     }
46
47     public static function semanticalError($message, $previous = null)
48     {
49         return new self('[Semantical Error] ' . $message, 0, $previous);
50     }
51
52     public static function invalidLockMode()
53     {
54         return new self('Invalid lock mode hint provided.');
55     }
56
57     public static function invalidParameterType($expected, $received)
58     {
59         return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.');
60     }
61
62     public static function invalidParameterPosition($pos)
63     {
64         return new self('Invalid parameter position: ' . $pos);
65     }
66
67     public static function invalidParameterNumber()
68     {
69         return new self("Invalid parameter number: number of bound variables does not match number of tokens");
70     }
71
72     public static function invalidParameterFormat($value)
73     {
74         return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.');
75     }
76
77     public static function unknownParameter($key)
78     {
79         return new self("Invalid parameter: token ".$key." is not defined in the query.");
80     }
81
82     public static function parameterTypeMissmatch()
83     {
84         return new self("DQL Query parameter and type numbers missmatch, but have to be exactly equal.");
85     }
86
87     public static function invalidPathExpression($pathExpr)
88     {
89         return new self(
90             "Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'."
91         );
92     }
93
94     public static function invalidLiteral($literal) {
95         return new self("Invalid literal '$literal'");
96     }
97
98     /**
99      * @param array $assoc
100      */
101     public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
102     {
103         return new self(
104             "Invalid query operation: Not allowed to iterate over fetch join collections ".
105             "in class ".$assoc['sourceEntity']." assocation ".$assoc['fieldName']
106         );
107     }
108
109     public static function partialObjectsAreDangerous()
110     {
111         return new self(
112             "Loading partial objects is dangerous. Fetch full objects or consider " .
113             "using a different fetch mode. If you really want partial objects, " .
114             "set the doctrine.forcePartialLoad query hint to TRUE."
115         );
116     }
117
118     public static function overwritingJoinConditionsNotYetSupported($assoc)
119     {
120         return new self(
121             "Unsupported query operation: It is not yet possible to overwrite the join ".
122             "conditions in class ".$assoc['sourceEntityName']." assocation ".$assoc['fieldName'].". ".
123             "Use WITH to append additional join conditions to the association."
124         );
125     }
126
127     public static function associationPathInverseSideNotSupported()
128     {
129         return new self(
130             "A single-valued association path expression to an inverse side is not supported".
131             " in DQL queries. Use an explicit join instead."
132         );
133     }
134
135     public static function iterateWithFetchJoinNotAllowed($assoc) {
136         return new self(
137             "Iterate with fetch join in class " . $assoc['sourceEntity'] .
138             " using association " . $assoc['fieldName'] . " not allowed."
139         );
140     }
141
142     public static function associationPathCompositeKeyNotSupported()
143     {
144         return new self(
145             "A single-valued association path expression to an entity with a composite primary ".
146             "key is not supported. Explicitly name the components of the composite primary key ".
147             "in the query."
148         );
149     }
150
151     public static function instanceOfUnrelatedClass($className, $rootClass)
152     {
153         return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " .
154                 "inheritance hierachy exists between these two classes.");
155     }
156 }