PageRenderTime 26ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php

https://github.com/nattaphat/hgis
PHP | 252 lines | 112 code | 21 blank | 119 comment | 2 complexity | 98ab7550670d9073ebe2e9e661b32b74 MD5 | raw file
  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. namespace Doctrine\ORM\Query;
  20. /**
  21. * Description of QueryException.
  22. *
  23. * @link www.doctrine-project.org
  24. * @since 2.0
  25. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  26. * @author Jonathan Wage <jonwage@gmail.com>
  27. * @author Roman Borschel <roman@code-factory.org>
  28. * @author Benjamin Eberlei <kontakt@beberlei.de>
  29. */
  30. class QueryException extends \Doctrine\ORM\ORMException
  31. {
  32. /**
  33. * @param string $dql
  34. *
  35. * @return QueryException
  36. */
  37. public static function dqlError($dql)
  38. {
  39. return new self($dql);
  40. }
  41. /**
  42. * @param string $message
  43. * @param \Exception|null $previous
  44. *
  45. * @return QueryException
  46. */
  47. public static function syntaxError($message, $previous = null)
  48. {
  49. return new self('[Syntax Error] ' . $message, 0, $previous);
  50. }
  51. /**
  52. * @param string $message
  53. * @param \Exception|null $previous
  54. *
  55. * @return QueryException
  56. */
  57. public static function semanticalError($message, $previous = null)
  58. {
  59. return new self('[Semantical Error] ' . $message, 0, $previous);
  60. }
  61. /**
  62. * @return QueryException
  63. */
  64. public static function invalidLockMode()
  65. {
  66. return new self('Invalid lock mode hint provided.');
  67. }
  68. /**
  69. * @param string $expected
  70. * @param string $received
  71. *
  72. * @return QueryException
  73. */
  74. public static function invalidParameterType($expected, $received)
  75. {
  76. return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.');
  77. }
  78. /**
  79. * @param string $pos
  80. *
  81. * @return QueryException
  82. */
  83. public static function invalidParameterPosition($pos)
  84. {
  85. return new self('Invalid parameter position: ' . $pos);
  86. }
  87. /**
  88. * @return QueryException
  89. */
  90. public static function invalidParameterNumber()
  91. {
  92. return new self("Invalid parameter number: number of bound variables does not match number of tokens");
  93. }
  94. /**
  95. * @param string $value
  96. *
  97. * @return QueryException
  98. */
  99. public static function invalidParameterFormat($value)
  100. {
  101. return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.');
  102. }
  103. /**
  104. * @param string $key
  105. *
  106. * @return QueryException
  107. */
  108. public static function unknownParameter($key)
  109. {
  110. return new self("Invalid parameter: token ".$key." is not defined in the query.");
  111. }
  112. /**
  113. * @return QueryException
  114. */
  115. public static function parameterTypeMismatch()
  116. {
  117. return new self("DQL Query parameter and type numbers mismatch, but have to be exactly equal.");
  118. }
  119. /**
  120. * @param object $pathExpr
  121. *
  122. * @return QueryException
  123. */
  124. public static function invalidPathExpression($pathExpr)
  125. {
  126. return new self(
  127. "Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'."
  128. );
  129. }
  130. /**
  131. * @param string $literal
  132. *
  133. * @return QueryException
  134. */
  135. public static function invalidLiteral($literal)
  136. {
  137. return new self("Invalid literal '$literal'");
  138. }
  139. /**
  140. * @param array $assoc
  141. *
  142. * @return QueryException
  143. */
  144. public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
  145. {
  146. return new self(
  147. "Invalid query operation: Not allowed to iterate over fetch join collections ".
  148. "in class ".$assoc['sourceEntity']." association ".$assoc['fieldName']
  149. );
  150. }
  151. /**
  152. * @return QueryException
  153. */
  154. public static function partialObjectsAreDangerous()
  155. {
  156. return new self(
  157. "Loading partial objects is dangerous. Fetch full objects or consider " .
  158. "using a different fetch mode. If you really want partial objects, " .
  159. "set the doctrine.forcePartialLoad query hint to TRUE."
  160. );
  161. }
  162. /**
  163. * @param array $assoc
  164. *
  165. * @return QueryException
  166. */
  167. public static function overwritingJoinConditionsNotYetSupported($assoc)
  168. {
  169. return new self(
  170. "Unsupported query operation: It is not yet possible to overwrite the join ".
  171. "conditions in class ".$assoc['sourceEntityName']." association ".$assoc['fieldName'].". ".
  172. "Use WITH to append additional join conditions to the association."
  173. );
  174. }
  175. /**
  176. * @return QueryException
  177. */
  178. public static function associationPathInverseSideNotSupported()
  179. {
  180. return new self(
  181. "A single-valued association path expression to an inverse side is not supported".
  182. " in DQL queries. Use an explicit join instead."
  183. );
  184. }
  185. /**
  186. * @param array $assoc
  187. *
  188. * @return QueryException
  189. */
  190. public static function iterateWithFetchJoinNotAllowed($assoc)
  191. {
  192. return new self(
  193. "Iterate with fetch join in class " . $assoc['sourceEntity'] .
  194. " using association " . $assoc['fieldName'] . " not allowed."
  195. );
  196. }
  197. /**
  198. * @return QueryException
  199. */
  200. public static function associationPathCompositeKeyNotSupported()
  201. {
  202. return new self(
  203. "A single-valued association path expression to an entity with a composite primary ".
  204. "key is not supported. Explicitly name the components of the composite primary key ".
  205. "in the query."
  206. );
  207. }
  208. /**
  209. * @param string $className
  210. * @param string $rootClass
  211. *
  212. * @return QueryException
  213. */
  214. public static function instanceOfUnrelatedClass($className, $rootClass)
  215. {
  216. return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " .
  217. "inheritance hierarchy exists between these two classes.");
  218. }
  219. /**
  220. * @param string $dqlAlias
  221. *
  222. * @return QueryException
  223. */
  224. public static function invalidQueryComponent($dqlAlias)
  225. {
  226. return new self(
  227. "Invalid query component given for DQL alias '" . $dqlAlias . "', ".
  228. "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys."
  229. );
  230. }
  231. }