vendor/doctrine/lib/Doctrine/ORM/Query/QueryException.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     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 invalidParameterType($expected, $received)
       
    51     {
       
    52         return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.');
       
    53     }
       
    54 
       
    55     public static function invalidParameterPosition($pos)
       
    56     {
       
    57         return new self('Invalid parameter position: ' . $pos);
       
    58     }
       
    59 
       
    60     public static function invalidParameterNumber()
       
    61     {
       
    62         return new self("Invalid parameter number: number of bound variables does not match number of tokens");
       
    63     }
       
    64 
       
    65     public static function invalidParameterFormat($value)
       
    66     {
       
    67         return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.');
       
    68     }
       
    69 
       
    70     public static function unknownParameter($key)
       
    71     {
       
    72         return new self("Invalid parameter: token ".$key." is not defined in the query.");
       
    73     }
       
    74 
       
    75     public static function invalidPathExpression($pathExpr)
       
    76     {
       
    77         return new self(
       
    78             "Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'."
       
    79         );
       
    80     }
       
    81 
       
    82     public static function invalidLiteral($literal) {
       
    83         return new self("Invalid literal '$literal'");
       
    84     }
       
    85 
       
    86     /**
       
    87      * @param Doctrine\ORM\Mapping\AssociationMapping $assoc
       
    88      */
       
    89     public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
       
    90     {
       
    91         return new self(
       
    92             "Invalid query operation: Not allowed to iterate over fetch join collections ".
       
    93             "in class ".$assoc['sourceEntity']." assocation ".$assoc['fieldName']
       
    94         );
       
    95     }
       
    96 
       
    97     public static function partialObjectsAreDangerous()
       
    98     {
       
    99         return new self(
       
   100             "Loading partial objects is dangerous. Fetch full objects or consider " .
       
   101             "using a different fetch mode. If you really want partial objects, " .
       
   102             "set the doctrine.forcePartialLoad query hint to TRUE."
       
   103         );
       
   104     }
       
   105 
       
   106     public static function overwritingJoinConditionsNotYetSupported($assoc)
       
   107     {
       
   108         return new self(
       
   109             "Unsupported query operation: It is not yet possible to overwrite the join ".
       
   110             "conditions in class ".$assoc['sourceEntityName']." assocation ".$assoc['fieldName'].". ".
       
   111             "Use WITH to append additional join conditions to the association."
       
   112         );
       
   113     }
       
   114 
       
   115     public static function associationPathInverseSideNotSupported()
       
   116     {
       
   117         return new self(
       
   118             "A single-valued association path expression to an inverse side is not supported".
       
   119             " in DQL queries. Use an explicit join instead."
       
   120         );
       
   121     }
       
   122 
       
   123     public static function iterateWithFetchJoinNotAllowed($assoc) {
       
   124         return new self(
       
   125             "Iterate with fetch join in class " . $assoc['sourceEntity'] .
       
   126             " using association " . $assoc['fieldName'] . " not allowed."
       
   127         );
       
   128     }
       
   129 
       
   130     public static function associationPathCompositeKeyNotSupported()
       
   131     {
       
   132         return new self(
       
   133             "A single-valued association path expression to an entity with a composite primary ".
       
   134             "key is not supported. Explicitly name the components of the composite primary key ".
       
   135             "in the query."
       
   136         );
       
   137     }
       
   138     
       
   139     public static function instanceOfUnrelatedClass($className, $rootClass)
       
   140     {
       
   141         return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " .
       
   142                 "inheritance hierachy exists between these two classes.");
       
   143     }
       
   144 }