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