QueryException.php 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. namespace Doctrine\ORM\Query;
  22. use Doctrine\ORM\Query\AST\PathExpression;
  23. /**
  24. * Description of QueryException
  25. *
  26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  27. * @link www.doctrine-project.org
  28. * @since 2.0
  29. * @version $Revision: 3938 $
  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 syntaxError($message)
  38. {
  39. return new self('[Syntax Error] ' . $message);
  40. }
  41. public static function semanticalError($message)
  42. {
  43. return new self('[Semantical Error] ' . $message);
  44. }
  45. public static function invalidParameterType($expected, $received)
  46. {
  47. return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.');
  48. }
  49. public static function invalidParameterPosition($pos)
  50. {
  51. return new self('Invalid parameter position: ' . $pos);
  52. }
  53. public static function invalidParameterNumber()
  54. {
  55. return new self("Invalid parameter number: number of bound variables does not match number of tokens");
  56. }
  57. public static function invalidParameterFormat($value)
  58. {
  59. return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.');
  60. }
  61. public static function unknownParameter($key)
  62. {
  63. return new self("Invalid parameter: token ".$key." is not defined in the query.");
  64. }
  65. public static function invalidPathExpression($pathExpr)
  66. {
  67. return new self(
  68. "Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'."
  69. );
  70. }
  71. public static function invalidLiteral($literal) {
  72. return new self("Invalid literal '$literal'");
  73. }
  74. /**
  75. * @param Doctrine\ORM\Mapping\AssociationMapping $assoc
  76. */
  77. public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
  78. {
  79. return new self(
  80. "Invalid query operation: Not allowed to iterate over fetch join collections ".
  81. "in class ".$assoc['sourceEntity']." assocation ".$assoc['fieldName']
  82. );
  83. }
  84. public static function partialObjectsAreDangerous()
  85. {
  86. return new self(
  87. "Loading partial objects is dangerous. Fetch full objects or consider " .
  88. "using a different fetch mode. If you really want partial objects, " .
  89. "set the doctrine.forcePartialLoad query hint to TRUE."
  90. );
  91. }
  92. public static function overwritingJoinConditionsNotYetSupported($assoc)
  93. {
  94. return new self(
  95. "Unsupported query operation: It is not yet possible to overwrite the join ".
  96. "conditions in class ".$assoc['sourceEntityName']." assocation ".$assoc['fieldName'].". ".
  97. "Use WITH to append additional join conditions to the association."
  98. );
  99. }
  100. public static function associationPathInverseSideNotSupported()
  101. {
  102. return new self(
  103. "A single-valued association path expression to an inverse side is not supported".
  104. " in DQL queries. Use an explicit join instead."
  105. );
  106. }
  107. public static function iterateWithFetchJoinNotAllowed($assoc) {
  108. return new self(
  109. "Iterate with fetch join in class " . $assoc['sourceEntity'] .
  110. " using association " . $assoc['fieldName'] . " not allowed."
  111. );
  112. }
  113. public static function associationPathCompositeKeyNotSupported()
  114. {
  115. return new self(
  116. "A single-valued association path expression to an entity with a composite primary ".
  117. "key is not supported. Explicitly name the components of the composite primary key ".
  118. "in the query."
  119. );
  120. }
  121. public static function instanceOfUnrelatedClass($className, $rootClass)
  122. {
  123. return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " .
  124. "inheritance hierachy exists between these two classes.");
  125. }
  126. }