QueryException.php 5.4 KB

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