Complex classes like SqlWalker often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SqlWalker, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 41 | class SqlWalker implements TreeWalker |
||
| 42 | { |
||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | const HINT_DISTINCT = 'doctrine.distinct'; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var ResultSetMapping |
||
| 50 | */ |
||
| 51 | private $rsm; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Counter for generating unique column aliases. |
||
| 55 | * |
||
| 56 | * @var integer |
||
| 57 | */ |
||
| 58 | private $aliasCounter = 0; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Counter for generating unique table aliases. |
||
| 62 | * |
||
| 63 | * @var integer |
||
| 64 | */ |
||
| 65 | private $tableAliasCounter = 0; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Counter for generating unique scalar result. |
||
| 69 | * |
||
| 70 | * @var integer |
||
| 71 | */ |
||
| 72 | private $scalarResultCounter = 1; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Counter for generating unique parameter indexes. |
||
| 76 | * |
||
| 77 | * @var integer |
||
| 78 | */ |
||
| 79 | private $sqlParamIndex = 0; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Counter for generating indexes. |
||
| 83 | * |
||
| 84 | * @var integer |
||
| 85 | */ |
||
| 86 | private $newObjectCounter = 0; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var ParserResult |
||
| 90 | */ |
||
| 91 | private $parserResult; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var \Doctrine\ORM\EntityManager |
||
| 95 | */ |
||
| 96 | private $em; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var \Doctrine\DBAL\Connection |
||
| 100 | */ |
||
| 101 | private $conn; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var \Doctrine\ORM\AbstractQuery |
||
| 105 | */ |
||
| 106 | private $query; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var array |
||
| 110 | */ |
||
| 111 | private $tableAliasMap = []; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Map from result variable names to their SQL column alias names. |
||
| 115 | * |
||
| 116 | * @var array |
||
| 117 | */ |
||
| 118 | private $scalarResultAliasMap = []; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Map from Table-Alias + Column-Name to OrderBy-Direction. |
||
| 122 | * |
||
| 123 | * @var array |
||
| 124 | */ |
||
| 125 | private $orderedColumnsMap = []; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Map from DQL-Alias + Field-Name to SQL Column Alias. |
||
| 129 | * |
||
| 130 | * @var array |
||
| 131 | */ |
||
| 132 | private $scalarFields = []; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Map of all components/classes that appear in the DQL query. |
||
| 136 | * |
||
| 137 | * @var array |
||
| 138 | */ |
||
| 139 | private $queryComponents; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * A list of classes that appear in non-scalar SelectExpressions. |
||
| 143 | * |
||
| 144 | * @var array |
||
| 145 | */ |
||
| 146 | private $selectedClasses = []; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * The DQL alias of the root class of the currently traversed query. |
||
| 150 | * |
||
| 151 | * @var array |
||
| 152 | */ |
||
| 153 | private $rootAliases = []; |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Flag that indicates whether to generate SQL table aliases in the SQL. |
||
| 157 | * These should only be generated for SELECT queries, not for UPDATE/DELETE. |
||
| 158 | * |
||
| 159 | * @var boolean |
||
| 160 | */ |
||
| 161 | private $useSqlTableAliases = true; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * The database platform abstraction. |
||
| 165 | * |
||
| 166 | * @var \Doctrine\DBAL\Platforms\AbstractPlatform |
||
| 167 | */ |
||
| 168 | private $platform; |
||
| 169 | |||
| 170 | /** |
||
| 171 | * The quote strategy. |
||
| 172 | * |
||
| 173 | * @var \Doctrine\ORM\Mapping\QuoteStrategy |
||
| 174 | */ |
||
| 175 | private $quoteStrategy; |
||
| 176 | |||
| 177 | /** |
||
| 178 | * {@inheritDoc} |
||
| 179 | */ |
||
| 180 | 684 | public function __construct($query, $parserResult, array $queryComponents) |
|
| 181 | { |
||
| 182 | 684 | $this->query = $query; |
|
| 183 | 684 | $this->parserResult = $parserResult; |
|
| 184 | 684 | $this->queryComponents = $queryComponents; |
|
| 185 | 684 | $this->rsm = $parserResult->getResultSetMapping(); |
|
| 186 | 684 | $this->em = $query->getEntityManager(); |
|
| 187 | 684 | $this->conn = $this->em->getConnection(); |
|
| 188 | 684 | $this->platform = $this->conn->getDatabasePlatform(); |
|
| 189 | 684 | $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy(); |
|
| 190 | 684 | } |
|
| 191 | |||
| 192 | /** |
||
| 193 | * Gets the Query instance used by the walker. |
||
| 194 | * |
||
| 195 | * @return Query. |
||
|
|
|||
| 196 | */ |
||
| 197 | public function getQuery() |
||
| 198 | { |
||
| 199 | return $this->query; |
||
| 200 | } |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Gets the Connection used by the walker. |
||
| 204 | * |
||
| 205 | * @return \Doctrine\DBAL\Connection |
||
| 206 | */ |
||
| 207 | 35 | public function getConnection() |
|
| 208 | { |
||
| 209 | 35 | return $this->conn; |
|
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Gets the EntityManager used by the walker. |
||
| 214 | * |
||
| 215 | * @return \Doctrine\ORM\EntityManager |
||
| 216 | */ |
||
| 217 | 21 | public function getEntityManager() |
|
| 218 | { |
||
| 219 | 21 | return $this->em; |
|
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Gets the information about a single query component. |
||
| 224 | * |
||
| 225 | * @param string $dqlAlias The DQL alias. |
||
| 226 | * |
||
| 227 | * @return array |
||
| 228 | */ |
||
| 229 | 17 | public function getQueryComponent($dqlAlias) |
|
| 230 | { |
||
| 231 | 17 | return $this->queryComponents[$dqlAlias]; |
|
| 232 | } |
||
| 233 | |||
| 234 | /** |
||
| 235 | * {@inheritdoc} |
||
| 236 | */ |
||
| 237 | public function getQueryComponents() |
||
| 238 | { |
||
| 239 | return $this->queryComponents; |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * {@inheritdoc} |
||
| 244 | */ |
||
| 245 | 1 | public function setQueryComponent($dqlAlias, array $queryComponent) |
|
| 246 | { |
||
| 247 | 1 | $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; |
|
| 248 | |||
| 249 | 1 | if (array_diff($requiredKeys, array_keys($queryComponent))) { |
|
| 250 | 1 | throw QueryException::invalidQueryComponent($dqlAlias); |
|
| 251 | } |
||
| 252 | |||
| 253 | $this->queryComponents[$dqlAlias] = $queryComponent; |
||
| 254 | } |
||
| 255 | |||
| 256 | /** |
||
| 257 | * {@inheritdoc} |
||
| 258 | */ |
||
| 259 | 678 | public function getExecutor($AST) |
|
| 260 | { |
||
| 261 | switch (true) { |
||
| 262 | 678 | case ($AST instanceof AST\DeleteStatement): |
|
| 263 | 38 | $primaryClass = $this->em->getClassMetadata($AST->deleteClause->abstractSchemaName); |
|
| 264 | |||
| 265 | 38 | return ($primaryClass->isInheritanceTypeJoined()) |
|
| 266 | 2 | ? new Exec\MultiTableDeleteExecutor($AST, $this) |
|
| 267 | 38 | : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); |
|
| 268 | |||
| 269 | 620 | case ($AST instanceof AST\UpdateStatement): |
|
| 270 | 27 | $primaryClass = $this->em->getClassMetadata($AST->updateClause->abstractSchemaName); |
|
| 271 | |||
| 272 | 27 | return ($primaryClass->isInheritanceTypeJoined()) |
|
| 273 | 3 | ? new Exec\MultiTableUpdateExecutor($AST, $this) |
|
| 274 | 27 | : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); |
|
| 275 | |||
| 276 | default: |
||
| 277 | 620 | return new Exec\SingleSelectExecutor($AST, $this); |
|
| 278 | } |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * Generates a unique, short SQL table alias. |
||
| 283 | * |
||
| 284 | * @param string $tableName Table name |
||
| 285 | * @param string $dqlAlias The DQL alias. |
||
| 286 | * |
||
| 287 | * @return string Generated table alias. |
||
| 288 | */ |
||
| 289 | 630 | public function getSQLTableAlias($tableName, $dqlAlias = '') |
|
| 290 | { |
||
| 291 | 630 | $tableName .= ($dqlAlias) ? '@[' . $dqlAlias . ']' : ''; |
|
| 292 | |||
| 293 | 630 | if ( ! isset($this->tableAliasMap[$tableName])) { |
|
| 294 | 630 | $this->tableAliasMap[$tableName] = (preg_match('/[a-z]/i', $tableName[0]) ? strtolower($tableName[0]) : 't') |
|
| 295 | 630 | . $this->tableAliasCounter++ . '_'; |
|
| 296 | } |
||
| 297 | |||
| 298 | 630 | return $this->tableAliasMap[$tableName]; |
|
| 299 | } |
||
| 300 | |||
| 301 | /** |
||
| 302 | * Forces the SqlWalker to use a specific alias for a table name, rather than |
||
| 303 | * generating an alias on its own. |
||
| 304 | * |
||
| 305 | * @param string $tableName |
||
| 306 | * @param string $alias |
||
| 307 | * @param string $dqlAlias |
||
| 308 | * |
||
| 309 | * @return string |
||
| 310 | */ |
||
| 311 | 63 | public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') |
|
| 312 | { |
||
| 313 | 63 | $tableName .= ($dqlAlias) ? '@[' . $dqlAlias . ']' : ''; |
|
| 314 | |||
| 315 | 63 | $this->tableAliasMap[$tableName] = $alias; |
|
| 316 | |||
| 317 | 63 | return $alias; |
|
| 318 | } |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Gets an SQL column alias for a column name. |
||
| 322 | * |
||
| 323 | * @param string $columnName |
||
| 324 | * |
||
| 325 | * @return string |
||
| 326 | */ |
||
| 327 | 620 | public function getSQLColumnAlias($columnName) |
|
| 328 | { |
||
| 329 | 620 | return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform); |
|
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * Generates the SQL JOINs that are necessary for Class Table Inheritance |
||
| 334 | * for the given class. |
||
| 335 | * |
||
| 336 | * @param ClassMetadata $class The class for which to generate the joins. |
||
| 337 | * @param string $dqlAlias The DQL alias of the class. |
||
| 338 | * |
||
| 339 | * @return string The SQL. |
||
| 340 | */ |
||
| 341 | 94 | private function _generateClassTableInheritanceJoins($class, $dqlAlias) |
|
| 342 | { |
||
| 343 | 94 | $sql = ''; |
|
| 344 | |||
| 345 | 94 | $baseTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias); |
|
| 346 | |||
| 347 | // INNER JOIN parent class tables |
||
| 348 | 94 | foreach ($class->parentClasses as $parentClassName) { |
|
| 349 | 64 | $parentClass = $this->em->getClassMetadata($parentClassName); |
|
| 350 | 64 | $tableAlias = $this->getSQLTableAlias($parentClass->getTableName(), $dqlAlias); |
|
| 351 | |||
| 352 | // If this is a joined association we must use left joins to preserve the correct result. |
||
| 353 | 64 | $sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER '; |
|
| 354 | 64 | $sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; |
|
| 355 | |||
| 356 | 64 | $sqlParts = []; |
|
| 357 | |||
| 358 | 64 | foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { |
|
| 359 | 64 | $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; |
|
| 360 | } |
||
| 361 | |||
| 362 | // Add filters on the root class |
||
| 363 | 64 | if ($filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) { |
|
| 364 | 1 | $sqlParts[] = $filterSql; |
|
| 365 | } |
||
| 366 | |||
| 367 | 64 | $sql .= implode(' AND ', $sqlParts); |
|
| 368 | } |
||
| 369 | |||
| 370 | // Ignore subclassing inclusion if partial objects is disallowed |
||
| 371 | 94 | if ($this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { |
|
| 372 | 21 | return $sql; |
|
| 373 | } |
||
| 374 | |||
| 375 | // LEFT JOIN child class tables |
||
| 376 | 73 | foreach ($class->subClasses as $subClassName) { |
|
| 377 | 35 | $subClass = $this->em->getClassMetadata($subClassName); |
|
| 378 | 35 | $tableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); |
|
| 379 | |||
| 380 | 35 | $sql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON '; |
|
| 381 | |||
| 382 | 35 | $sqlParts = []; |
|
| 383 | |||
| 384 | 35 | foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) { |
|
| 385 | 35 | $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; |
|
| 386 | } |
||
| 387 | |||
| 388 | 35 | $sql .= implode(' AND ', $sqlParts); |
|
| 389 | } |
||
| 390 | |||
| 391 | 73 | return $sql; |
|
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @return string |
||
| 396 | */ |
||
| 397 | 613 | private function _generateOrderedCollectionOrderByItems() |
|
| 398 | { |
||
| 399 | 613 | $orderedColumns = []; |
|
| 400 | |||
| 401 | 613 | foreach ($this->selectedClasses as $selectedClass) { |
|
| 402 | 477 | $dqlAlias = $selectedClass['dqlAlias']; |
|
| 403 | 477 | $qComp = $this->queryComponents[$dqlAlias]; |
|
| 404 | |||
| 405 | 477 | if ( ! isset($qComp['relation']['orderBy'])) { |
|
| 406 | 477 | continue; |
|
| 407 | } |
||
| 408 | |||
| 409 | 6 | $persister = $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name); |
|
| 410 | |||
| 411 | 6 | foreach ($qComp['relation']['orderBy'] as $fieldName => $orientation) { |
|
| 412 | 6 | $columnName = $this->quoteStrategy->getColumnName($fieldName, $qComp['metadata'], $this->platform); |
|
| 413 | 6 | $tableName = ($qComp['metadata']->isInheritanceTypeJoined()) |
|
| 414 | 1 | ? $persister->getOwningTable($fieldName) |
|
| 415 | 6 | : $qComp['metadata']->getTableName(); |
|
| 416 | |||
| 417 | 6 | $orderedColumn = $this->getSQLTableAlias($tableName, $dqlAlias) . '.' . $columnName; |
|
| 418 | |||
| 419 | // OrderByClause should replace an ordered relation. see - DDC-2475 |
||
| 420 | 6 | if (isset($this->orderedColumnsMap[$orderedColumn])) { |
|
| 421 | 1 | continue; |
|
| 422 | } |
||
| 423 | |||
| 424 | 6 | $this->orderedColumnsMap[$orderedColumn] = $orientation; |
|
| 425 | 6 | $orderedColumns[] = $orderedColumn . ' ' . $orientation; |
|
| 426 | } |
||
| 427 | } |
||
| 428 | |||
| 429 | 613 | return implode(', ', $orderedColumns); |
|
| 430 | } |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Generates a discriminator column SQL condition for the class with the given DQL alias. |
||
| 434 | * |
||
| 435 | * @param array $dqlAliases List of root DQL aliases to inspect for discriminator restrictions. |
||
| 436 | * |
||
| 437 | * @return string |
||
| 438 | */ |
||
| 439 | 672 | private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases) |
|
| 440 | { |
||
| 441 | 672 | $sqlParts = []; |
|
| 442 | |||
| 443 | 672 | foreach ($dqlAliases as $dqlAlias) { |
|
| 444 | 672 | $class = $this->queryComponents[$dqlAlias]['metadata']; |
|
| 445 | |||
| 446 | 672 | if ( ! $class->isInheritanceTypeSingleTable()) continue; |
|
| 447 | |||
| 448 | 39 | $conn = $this->em->getConnection(); |
|
| 449 | 39 | $values = []; |
|
| 450 | |||
| 451 | 39 | if ($class->discriminatorValue !== null) { // discriminators can be 0 |
|
| 452 | 20 | $values[] = $conn->quote($class->discriminatorValue); |
|
| 453 | } |
||
| 454 | |||
| 455 | 39 | foreach ($class->subClasses as $subclassName) { |
|
| 456 | 29 | $values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue); |
|
| 457 | } |
||
| 458 | |||
| 459 | 39 | $sqlTableAlias = ($this->useSqlTableAliases) |
|
| 460 | 34 | ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.' |
|
| 461 | 39 | : ''; |
|
| 462 | |||
| 463 | 39 | $sqlParts[] = $sqlTableAlias . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')'; |
|
| 464 | } |
||
| 465 | |||
| 466 | 672 | $sql = implode(' AND ', $sqlParts); |
|
| 467 | |||
| 468 | 672 | return (count($sqlParts) > 1) ? '(' . $sql . ')' : $sql; |
|
| 469 | } |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Generates the filter SQL for a given entity and table alias. |
||
| 473 | * |
||
| 474 | * @param ClassMetadata $targetEntity Metadata of the target entity. |
||
| 475 | * @param string $targetTableAlias The table alias of the joined/selected table. |
||
| 476 | * |
||
| 477 | * @return string The SQL query part to add to a query. |
||
| 478 | */ |
||
| 479 | 315 | private function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) |
|
| 480 | { |
||
| 481 | 315 | if (!$this->em->hasFilters()) { |
|
| 482 | 277 | return ''; |
|
| 483 | } |
||
| 484 | |||
| 485 | 43 | switch($targetEntity->inheritanceType) { |
|
| 486 | 43 | case ClassMetadata::INHERITANCE_TYPE_NONE: |
|
| 487 | 33 | break; |
|
| 488 | 10 | case ClassMetadata::INHERITANCE_TYPE_JOINED: |
|
| 489 | // The classes in the inheritance will be added to the query one by one, |
||
| 490 | // but only the root node is getting filtered |
||
| 491 | 6 | if ($targetEntity->name !== $targetEntity->rootEntityName) { |
|
| 492 | 4 | return ''; |
|
| 493 | } |
||
| 494 | 6 | break; |
|
| 495 | 4 | case ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE: |
|
| 496 | // With STI the table will only be queried once, make sure that the filters |
||
| 497 | // are added to the root entity |
||
| 498 | 4 | $targetEntity = $this->em->getClassMetadata($targetEntity->rootEntityName); |
|
| 499 | 4 | break; |
|
| 500 | default: |
||
| 501 | //@todo: throw exception? |
||
| 502 | return ''; |
||
| 503 | } |
||
| 504 | |||
| 505 | 43 | $filterClauses = []; |
|
| 506 | 43 | foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { |
|
| 507 | 10 | if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { |
|
| 508 | 10 | $filterClauses[] = '(' . $filterExpr . ')'; |
|
| 509 | } |
||
| 510 | } |
||
| 511 | |||
| 512 | 43 | return implode(' AND ', $filterClauses); |
|
| 513 | } |
||
| 514 | |||
| 515 | /** |
||
| 516 | * {@inheritdoc} |
||
| 517 | */ |
||
| 518 | 620 | public function walkSelectStatement(AST\SelectStatement $AST) |
|
| 519 | { |
||
| 520 | 620 | $limit = $this->query->getMaxResults(); |
|
| 521 | 620 | $offset = $this->query->getFirstResult(); |
|
| 522 | 620 | $lockMode = $this->query->getHint(Query::HINT_LOCK_MODE); |
|
| 523 | 620 | $sql = $this->walkSelectClause($AST->selectClause) |
|
| 524 | 620 | . $this->walkFromClause($AST->fromClause) |
|
| 525 | 617 | . $this->walkWhereClause($AST->whereClause); |
|
| 526 | |||
| 527 | 614 | if ($AST->groupByClause) { |
|
| 528 | 23 | $sql .= $this->walkGroupByClause($AST->groupByClause); |
|
| 529 | } |
||
| 530 | |||
| 531 | 614 | if ($AST->havingClause) { |
|
| 532 | 14 | $sql .= $this->walkHavingClause($AST->havingClause); |
|
| 533 | } |
||
| 534 | |||
| 535 | 614 | if ($AST->orderByClause) { |
|
| 536 | 142 | $sql .= $this->walkOrderByClause($AST->orderByClause); |
|
| 537 | } |
||
| 538 | |||
| 539 | 613 | if ( ! $AST->orderByClause && ($orderBySql = $this->_generateOrderedCollectionOrderByItems())) { |
|
| 540 | 6 | $sql .= ' ORDER BY ' . $orderBySql; |
|
| 541 | } |
||
| 542 | |||
| 543 | 613 | if ($limit !== null || $offset !== null) { |
|
| 544 | 39 | $sql = $this->platform->modifyLimitQuery($sql, $limit, $offset); |
|
| 545 | } |
||
| 546 | |||
| 547 | 613 | if ($lockMode === null || $lockMode === false || $lockMode === LockMode::NONE) { |
|
| 548 | 608 | return $sql; |
|
| 549 | } |
||
| 550 | |||
| 551 | 5 | if ($lockMode === LockMode::PESSIMISTIC_READ) { |
|
| 552 | 3 | return $sql . ' ' . $this->platform->getReadLockSQL(); |
|
| 553 | } |
||
| 554 | |||
| 555 | 2 | if ($lockMode === LockMode::PESSIMISTIC_WRITE) { |
|
| 556 | 1 | return $sql . ' ' . $this->platform->getWriteLockSQL(); |
|
| 557 | } |
||
| 558 | |||
| 559 | 1 | if ($lockMode !== LockMode::OPTIMISTIC) { |
|
| 560 | throw QueryException::invalidLockMode(); |
||
| 561 | } |
||
| 562 | |||
| 563 | 1 | foreach ($this->selectedClasses as $selectedClass) { |
|
| 564 | 1 | if ( ! $selectedClass['class']->isVersioned) { |
|
| 565 | 1 | throw OptimisticLockException::lockFailed($selectedClass['class']->name); |
|
| 566 | } |
||
| 567 | } |
||
| 568 | |||
| 569 | return $sql; |
||
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * {@inheritdoc} |
||
| 574 | */ |
||
| 575 | 24 | public function walkUpdateStatement(AST\UpdateStatement $AST) |
|
| 576 | { |
||
| 577 | 24 | $this->useSqlTableAliases = false; |
|
| 578 | 24 | $this->rsm->isSelect = false; |
|
| 579 | |||
| 580 | 24 | return $this->walkUpdateClause($AST->updateClause) |
|
| 581 | 24 | . $this->walkWhereClause($AST->whereClause); |
|
| 582 | } |
||
| 583 | |||
| 584 | /** |
||
| 585 | * {@inheritdoc} |
||
| 586 | */ |
||
| 587 | 36 | public function walkDeleteStatement(AST\DeleteStatement $AST) |
|
| 588 | { |
||
| 589 | 36 | $this->useSqlTableAliases = false; |
|
| 590 | 36 | $this->rsm->isSelect = false; |
|
| 591 | |||
| 592 | 36 | return $this->walkDeleteClause($AST->deleteClause) |
|
| 593 | 36 | . $this->walkWhereClause($AST->whereClause); |
|
| 594 | } |
||
| 595 | |||
| 596 | /** |
||
| 597 | * Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL. |
||
| 598 | * This one differs of ->walkIdentificationVariable() because it generates the entity identifiers. |
||
| 599 | * |
||
| 600 | * @param string $identVariable |
||
| 601 | * |
||
| 602 | * @return string |
||
| 603 | */ |
||
| 604 | 2 | public function walkEntityIdentificationVariable($identVariable) |
|
| 605 | { |
||
| 606 | 2 | $class = $this->queryComponents[$identVariable]['metadata']; |
|
| 607 | 2 | $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); |
|
| 608 | 2 | $sqlParts = []; |
|
| 609 | |||
| 610 | 2 | foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) { |
|
| 611 | 2 | $sqlParts[] = $tableAlias . '.' . $columnName; |
|
| 612 | } |
||
| 613 | |||
| 614 | 2 | return implode(', ', $sqlParts); |
|
| 615 | } |
||
| 616 | |||
| 617 | /** |
||
| 618 | * Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL. |
||
| 619 | * |
||
| 620 | * @param string $identificationVariable |
||
| 621 | * @param string $fieldName |
||
| 622 | * |
||
| 623 | * @return string The SQL. |
||
| 624 | */ |
||
| 625 | 419 | public function walkIdentificationVariable($identificationVariable, $fieldName = null) |
|
| 626 | { |
||
| 627 | 419 | $class = $this->queryComponents[$identificationVariable]['metadata']; |
|
| 628 | |||
| 629 | if ( |
||
| 630 | 419 | $fieldName !== null && $class->isInheritanceTypeJoined() && |
|
| 631 | 419 | isset($class->fieldMappings[$fieldName]['inherited']) |
|
| 632 | ) { |
||
| 633 | 37 | $class = $this->em->getClassMetadata($class->fieldMappings[$fieldName]['inherited']); |
|
| 634 | } |
||
| 635 | |||
| 636 | 419 | return $this->getSQLTableAlias($class->getTableName(), $identificationVariable); |
|
| 637 | } |
||
| 638 | |||
| 639 | /** |
||
| 640 | * {@inheritdoc} |
||
| 641 | */ |
||
| 642 | 486 | public function walkPathExpression($pathExpr) |
|
| 643 | { |
||
| 644 | 486 | $sql = ''; |
|
| 645 | |||
| 646 | 486 | switch ($pathExpr->type) { |
|
| 647 | 486 | case AST\PathExpression::TYPE_STATE_FIELD: |
|
| 648 | 466 | $fieldName = $pathExpr->field; |
|
| 649 | 466 | $dqlAlias = $pathExpr->identificationVariable; |
|
| 650 | 466 | $class = $this->queryComponents[$dqlAlias]['metadata']; |
|
| 651 | |||
| 652 | 466 | if ($this->useSqlTableAliases) { |
|
| 653 | 419 | $sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.'; |
|
| 654 | } |
||
| 655 | |||
| 656 | 466 | $sql .= $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); |
|
| 657 | 466 | break; |
|
| 658 | |||
| 659 | 61 | case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION: |
|
| 660 | // 1- the owning side: |
||
| 661 | // Just use the foreign key, i.e. u.group_id |
||
| 662 | 61 | $fieldName = $pathExpr->field; |
|
| 663 | 61 | $dqlAlias = $pathExpr->identificationVariable; |
|
| 664 | 61 | $class = $this->queryComponents[$dqlAlias]['metadata']; |
|
| 665 | |||
| 666 | 61 | if (isset($class->associationMappings[$fieldName]['inherited'])) { |
|
| 667 | 2 | $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]['inherited']); |
|
| 668 | } |
||
| 669 | |||
| 670 | 61 | $assoc = $class->associationMappings[$fieldName]; |
|
| 671 | |||
| 672 | 61 | if ( ! $assoc['isOwningSide']) { |
|
| 673 | 2 | throw QueryException::associationPathInverseSideNotSupported(); |
|
| 674 | } |
||
| 675 | |||
| 676 | // COMPOSITE KEYS NOT (YET?) SUPPORTED |
||
| 677 | 59 | if (count($assoc['sourceToTargetKeyColumns']) > 1) { |
|
| 678 | 1 | throw QueryException::associationPathCompositeKeyNotSupported(); |
|
| 679 | } |
||
| 680 | |||
| 681 | 58 | if ($this->useSqlTableAliases) { |
|
| 682 | 55 | $sql .= $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.'; |
|
| 683 | } |
||
| 684 | |||
| 685 | 58 | $sql .= reset($assoc['targetToSourceKeyColumns']); |
|
| 686 | 58 | break; |
|
| 687 | |||
| 688 | default: |
||
| 689 | throw QueryException::invalidPathExpression($pathExpr); |
||
| 690 | } |
||
| 691 | |||
| 692 | 483 | return $sql; |
|
| 693 | } |
||
| 694 | |||
| 695 | /** |
||
| 696 | * {@inheritdoc} |
||
| 697 | */ |
||
| 698 | 620 | public function walkSelectClause($selectClause) |
|
| 699 | { |
||
| 700 | 620 | $sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : ''); |
|
| 701 | 620 | $sqlSelectExpressions = array_filter(array_map([$this, 'walkSelectExpression'], $selectClause->selectExpressions)); |
|
| 702 | |||
| 703 | 620 | if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) == true && $selectClause->isDistinct) { |
|
| 704 | $this->query->setHint(self::HINT_DISTINCT, true); |
||
| 705 | } |
||
| 706 | |||
| 707 | 620 | $addMetaColumns = ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD) && |
|
| 708 | 457 | $this->query->getHydrationMode() == Query::HYDRATE_OBJECT |
|
| 709 | || |
||
| 710 | 288 | $this->query->getHydrationMode() != Query::HYDRATE_OBJECT && |
|
| 711 | 620 | $this->query->getHint(Query::HINT_INCLUDE_META_COLUMNS); |
|
| 712 | |||
| 713 | 620 | foreach ($this->selectedClasses as $selectedClass) { |
|
| 714 | 484 | $class = $selectedClass['class']; |
|
| 715 | 484 | $dqlAlias = $selectedClass['dqlAlias']; |
|
| 716 | 484 | $resultAlias = $selectedClass['resultAlias']; |
|
| 717 | |||
| 718 | // Register as entity or joined entity result |
||
| 719 | 484 | if ($this->queryComponents[$dqlAlias]['relation'] === null) { |
|
| 720 | 484 | $this->rsm->addEntityResult($class->name, $dqlAlias, $resultAlias); |
|
| 721 | } else { |
||
| 722 | 157 | $this->rsm->addJoinedEntityResult( |
|
| 723 | 157 | $class->name, |
|
| 724 | $dqlAlias, |
||
| 725 | 157 | $this->queryComponents[$dqlAlias]['parent'], |
|
| 726 | 157 | $this->queryComponents[$dqlAlias]['relation']['fieldName'] |
|
| 727 | ); |
||
| 728 | } |
||
| 729 | |||
| 730 | 484 | if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { |
|
| 731 | // Add discriminator columns to SQL |
||
| 732 | 93 | $rootClass = $this->em->getClassMetadata($class->rootEntityName); |
|
| 733 | 93 | $tblAlias = $this->getSQLTableAlias($rootClass->getTableName(), $dqlAlias); |
|
| 734 | 93 | $discrColumn = $rootClass->discriminatorColumn; |
|
| 735 | 93 | $columnAlias = $this->getSQLColumnAlias($discrColumn['name']); |
|
| 736 | |||
| 737 | 93 | $sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias; |
|
| 738 | |||
| 739 | 93 | $this->rsm->setDiscriminatorColumn($dqlAlias, $columnAlias); |
|
| 740 | 93 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn['fieldName'], false, $discrColumn['type']); |
|
| 741 | } |
||
| 742 | |||
| 743 | // Add foreign key columns to SQL, if necessary |
||
| 744 | 484 | if ( ! $addMetaColumns && ! $class->containsForeignIdentifier) { |
|
| 745 | 180 | continue; |
|
| 746 | } |
||
| 747 | |||
| 748 | // Add foreign key columns of class and also parent classes |
||
| 749 | 354 | foreach ($class->associationMappings as $assoc) { |
|
| 750 | 314 | if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { |
|
| 751 | 263 | continue; |
|
| 752 | 281 | } else if ( !$addMetaColumns && !isset($assoc['id'])) { |
|
| 753 | continue; |
||
| 754 | } |
||
| 755 | |||
| 756 | 281 | $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); |
|
| 757 | 281 | $isIdentifier = (isset($assoc['id']) && $assoc['id'] === true); |
|
| 758 | 281 | $owningClass = (isset($assoc['inherited'])) ? $this->em->getClassMetadata($assoc['inherited']) : $class; |
|
| 759 | 281 | $sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias); |
|
| 760 | |||
| 761 | 281 | foreach ($assoc['joinColumns'] as $joinColumn) { |
|
| 762 | 281 | $columnName = $joinColumn['name']; |
|
| 763 | 281 | $columnAlias = $this->getSQLColumnAlias($columnName); |
|
| 764 | 281 | $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); |
|
| 765 | |||
| 766 | 281 | $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); |
|
| 767 | 281 | $sqlSelectExpressions[] = $sqlTableAlias . '.' . $quotedColumnName . ' AS ' . $columnAlias; |
|
| 768 | |||
| 769 | 281 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $isIdentifier, $columnType); |
|
| 770 | } |
||
| 771 | } |
||
| 772 | |||
| 773 | // Add foreign key columns to SQL, if necessary |
||
| 774 | 354 | if ( ! $addMetaColumns) { |
|
| 775 | 8 | continue; |
|
| 776 | } |
||
| 777 | |||
| 778 | // Add foreign key columns of subclasses |
||
| 779 | 349 | foreach ($class->subClasses as $subClassName) { |
|
| 780 | 34 | $subClass = $this->em->getClassMetadata($subClassName); |
|
| 781 | 34 | $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); |
|
| 782 | |||
| 783 | 34 | foreach ($subClass->associationMappings as $assoc) { |
|
| 784 | // Skip if association is inherited |
||
| 785 | 27 | if (isset($assoc['inherited'])) continue; |
|
| 786 | |||
| 787 | 16 | if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { |
|
| 788 | 14 | $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); |
|
| 789 | |||
| 790 | 14 | foreach ($assoc['joinColumns'] as $joinColumn) { |
|
| 791 | 14 | $columnName = $joinColumn['name']; |
|
| 792 | 14 | $columnAlias = $this->getSQLColumnAlias($columnName); |
|
| 793 | 14 | $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); |
|
| 794 | |||
| 795 | 14 | $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform); |
|
| 796 | 14 | $sqlSelectExpressions[] = $sqlTableAlias . '.' . $quotedColumnName . ' AS ' . $columnAlias; |
|
| 797 | |||
| 798 | 349 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $subClass->isIdentifier($columnName), $columnType); |
|
| 799 | } |
||
| 800 | } |
||
| 801 | } |
||
| 802 | } |
||
| 803 | } |
||
| 804 | |||
| 805 | 620 | $sql .= implode(', ', $sqlSelectExpressions); |
|
| 806 | |||
| 807 | 620 | return $sql; |
|
| 808 | } |
||
| 809 | |||
| 810 | /** |
||
| 811 | * {@inheritdoc} |
||
| 812 | */ |
||
| 813 | 621 | public function walkFromClause($fromClause) |
|
| 824 | |||
| 825 | /** |
||
| 826 | * Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL. |
||
| 827 | * |
||
| 828 | * @param AST\IdentificationVariableDeclaration $identificationVariableDecl |
||
| 829 | * |
||
| 830 | * @return string |
||
| 831 | */ |
||
| 832 | 622 | public function walkIdentificationVariableDeclaration($identificationVariableDecl) |
|
| 846 | |||
| 847 | /** |
||
| 848 | * Walks down a IndexBy AST node. |
||
| 849 | * |
||
| 850 | * @param AST\IndexBy $indexBy |
||
| 851 | * |
||
| 852 | * @return void |
||
| 853 | */ |
||
| 854 | 8 | public function walkIndexBy($indexBy) |
|
| 868 | |||
| 869 | /** |
||
| 870 | * Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. |
||
| 871 | * |
||
| 872 | * @param AST\RangeVariableDeclaration $rangeVariableDeclaration |
||
| 873 | * |
||
| 874 | * @return string |
||
| 875 | */ |
||
| 876 | 622 | public function walkRangeVariableDeclaration($rangeVariableDeclaration) |
|
| 897 | |||
| 898 | /** |
||
| 899 | * Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL. |
||
| 900 | * |
||
| 901 | * @param AST\JoinAssociationDeclaration $joinAssociationDeclaration |
||
| 902 | * @param int $joinType |
||
| 903 | * @param AST\ConditionalExpression $condExpr |
||
| 904 | * |
||
| 905 | * @return string |
||
| 906 | * |
||
| 907 | * @throws QueryException |
||
| 908 | */ |
||
| 909 | 226 | public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null) |
|
| 1064 | |||
| 1065 | /** |
||
| 1066 | * {@inheritdoc} |
||
| 1067 | */ |
||
| 1068 | 63 | public function walkFunction($function) |
|
| 1072 | |||
| 1073 | /** |
||
| 1074 | * {@inheritdoc} |
||
| 1075 | */ |
||
| 1076 | 153 | public function walkOrderByClause($orderByClause) |
|
| 1086 | |||
| 1087 | /** |
||
| 1088 | * {@inheritdoc} |
||
| 1089 | */ |
||
| 1090 | 171 | public function walkOrderByItem($orderByItem) |
|
| 1106 | |||
| 1107 | /** |
||
| 1108 | * {@inheritdoc} |
||
| 1109 | */ |
||
| 1110 | 14 | public function walkHavingClause($havingClause) |
|
| 1114 | |||
| 1115 | /** |
||
| 1116 | * {@inheritdoc} |
||
| 1117 | */ |
||
| 1118 | 243 | public function walkJoin($join) |
|
| 1171 | |||
| 1172 | /** |
||
| 1173 | * Walks down a CoalesceExpression AST node and generates the corresponding SQL. |
||
| 1174 | * |
||
| 1175 | * @param AST\CoalesceExpression $coalesceExpression |
||
| 1176 | * |
||
| 1177 | * @return string The SQL. |
||
| 1178 | */ |
||
| 1179 | 2 | public function walkCoalesceExpression($coalesceExpression) |
|
| 1193 | |||
| 1194 | /** |
||
| 1195 | * Walks down a NullIfExpression AST node and generates the corresponding SQL. |
||
| 1196 | * |
||
| 1197 | * @param AST\NullIfExpression $nullIfExpression |
||
| 1198 | * |
||
| 1199 | * @return string The SQL. |
||
| 1200 | */ |
||
| 1201 | 3 | public function walkNullIfExpression($nullIfExpression) |
|
| 1213 | |||
| 1214 | /** |
||
| 1215 | * Walks down a GeneralCaseExpression AST node and generates the corresponding SQL. |
||
| 1216 | * |
||
| 1217 | * @param AST\GeneralCaseExpression $generalCaseExpression |
||
| 1218 | * |
||
| 1219 | * @return string The SQL. |
||
| 1220 | */ |
||
| 1221 | 9 | public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression) |
|
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Walks down a SimpleCaseExpression AST node and generates the corresponding SQL. |
||
| 1237 | * |
||
| 1238 | * @param AST\SimpleCaseExpression $simpleCaseExpression |
||
| 1239 | * |
||
| 1240 | * @return string The SQL. |
||
| 1241 | */ |
||
| 1242 | 5 | public function walkSimpleCaseExpression($simpleCaseExpression) |
|
| 1255 | |||
| 1256 | /** |
||
| 1257 | * {@inheritdoc} |
||
| 1258 | */ |
||
| 1259 | 620 | public function walkSelectExpression($selectExpression) |
|
| 1435 | |||
| 1436 | /** |
||
| 1437 | * {@inheritdoc} |
||
| 1438 | */ |
||
| 1439 | public function walkQuantifiedExpression($qExpr) |
||
| 1443 | |||
| 1444 | /** |
||
| 1445 | * {@inheritdoc} |
||
| 1446 | */ |
||
| 1447 | 33 | public function walkSubselect($subselect) |
|
| 1468 | |||
| 1469 | /** |
||
| 1470 | * {@inheritdoc} |
||
| 1471 | */ |
||
| 1472 | 33 | public function walkSubselectFromClause($subselectFromClause) |
|
| 1483 | |||
| 1484 | /** |
||
| 1485 | * {@inheritdoc} |
||
| 1486 | */ |
||
| 1487 | 33 | public function walkSimpleSelectClause($simpleSelectClause) |
|
| 1492 | |||
| 1493 | /** |
||
| 1494 | * @param \Doctrine\ORM\Query\AST\ParenthesisExpression $parenthesisExpression |
||
| 1495 | * |
||
| 1496 | * @return string. |
||
| 1497 | */ |
||
| 1498 | 22 | public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression) |
|
| 1502 | |||
| 1503 | /** |
||
| 1504 | * @param AST\NewObjectExpression $newObjectExpression |
||
| 1505 | * |
||
| 1506 | * @return string The SQL. |
||
| 1507 | */ |
||
| 1508 | 22 | public function walkNewObject($newObjectExpression, $newObjectResultAlias=null) |
|
| 1567 | |||
| 1568 | /** |
||
| 1569 | * {@inheritdoc} |
||
| 1570 | */ |
||
| 1571 | 33 | public function walkSimpleSelectExpression($simpleSelectExpression) |
|
| 1624 | |||
| 1625 | /** |
||
| 1626 | * {@inheritdoc} |
||
| 1627 | */ |
||
| 1628 | 75 | public function walkAggregateExpression($aggExpression) |
|
| 1633 | |||
| 1634 | /** |
||
| 1635 | * {@inheritdoc} |
||
| 1636 | */ |
||
| 1637 | 23 | public function walkGroupByClause($groupByClause) |
|
| 1647 | |||
| 1648 | /** |
||
| 1649 | * {@inheritdoc} |
||
| 1650 | */ |
||
| 1651 | 23 | public function walkGroupByItem($groupByItem) |
|
| 1694 | |||
| 1695 | /** |
||
| 1696 | * {@inheritdoc} |
||
| 1697 | */ |
||
| 1698 | 36 | public function walkDeleteClause(AST\DeleteClause $deleteClause) |
|
| 1709 | |||
| 1710 | /** |
||
| 1711 | * {@inheritdoc} |
||
| 1712 | */ |
||
| 1713 | 24 | public function walkUpdateClause($updateClause) |
|
| 1726 | |||
| 1727 | /** |
||
| 1728 | * {@inheritdoc} |
||
| 1729 | */ |
||
| 1730 | 27 | public function walkUpdateItem($updateItem) |
|
| 1756 | |||
| 1757 | /** |
||
| 1758 | * {@inheritdoc} |
||
| 1759 | */ |
||
| 1760 | 675 | public function walkWhereClause($whereClause) |
|
| 1795 | |||
| 1796 | /** |
||
| 1797 | * {@inheritdoc} |
||
| 1798 | */ |
||
| 1799 | 362 | public function walkConditionalExpression($condExpr) |
|
| 1809 | |||
| 1810 | /** |
||
| 1811 | * {@inheritdoc} |
||
| 1812 | */ |
||
| 1813 | 362 | public function walkConditionalTerm($condTerm) |
|
| 1823 | |||
| 1824 | /** |
||
| 1825 | * {@inheritdoc} |
||
| 1826 | */ |
||
| 1827 | 362 | public function walkConditionalFactor($factor) |
|
| 1835 | |||
| 1836 | /** |
||
| 1837 | * {@inheritdoc} |
||
| 1838 | */ |
||
| 1839 | 362 | public function walkConditionalPrimary($primary) |
|
| 1851 | |||
| 1852 | /** |
||
| 1853 | * {@inheritdoc} |
||
| 1854 | */ |
||
| 1855 | 5 | public function walkExistsExpression($existsExpr) |
|
| 1863 | |||
| 1864 | /** |
||
| 1865 | * {@inheritdoc} |
||
| 1866 | */ |
||
| 1867 | 6 | public function walkCollectionMemberExpression($collMemberExpr) |
|
| 1973 | |||
| 1974 | /** |
||
| 1975 | * {@inheritdoc} |
||
| 1976 | */ |
||
| 1977 | 3 | public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) |
|
| 1984 | |||
| 1985 | /** |
||
| 1986 | * {@inheritdoc} |
||
| 1987 | */ |
||
| 1988 | 11 | public function walkNullComparisonExpression($nullCompExpr) |
|
| 2005 | |||
| 2006 | /** |
||
| 2007 | * {@inheritdoc} |
||
| 2008 | */ |
||
| 2009 | 85 | public function walkInExpression($inExpr) |
|
| 2021 | |||
| 2022 | /** |
||
| 2023 | * {@inheritdoc} |
||
| 2024 | * @throws \Doctrine\ORM\Query\QueryException |
||
| 2025 | */ |
||
| 2026 | 12 | public function walkInstanceOfExpression($instanceOfExpr) |
|
| 2027 | { |
||
| 2028 | 12 | $sql = ''; |
|
| 2029 | |||
| 2030 | 12 | $dqlAlias = $instanceOfExpr->identificationVariable; |
|
| 2031 | 12 | $discrClass = $class = $this->queryComponents[$dqlAlias]['metadata']; |
|
| 2032 | |||
| 2033 | 12 | if ($class->discriminatorColumn) { |
|
| 2034 | 12 | $discrClass = $this->em->getClassMetadata($class->rootEntityName); |
|
| 2035 | } |
||
| 2046 | |||
| 2047 | /** |
||
| 2048 | * {@inheritdoc} |
||
| 2049 | */ |
||
| 2050 | 77 | public function walkInParameter($inParam) |
|
| 2056 | |||
| 2057 | /** |
||
| 2058 | * {@inheritdoc} |
||
| 2059 | */ |
||
| 2060 | 148 | public function walkLiteral($literal) |
|
| 2076 | |||
| 2077 | /** |
||
| 2078 | * {@inheritdoc} |
||
| 2079 | */ |
||
| 2080 | 6 | public function walkBetweenExpression($betweenExpr) |
|
| 2093 | |||
| 2094 | /** |
||
| 2095 | * {@inheritdoc} |
||
| 2096 | */ |
||
| 2097 | 9 | public function walkLikeExpression($likeExpr) |
|
| 2122 | |||
| 2123 | /** |
||
| 2124 | * {@inheritdoc} |
||
| 2125 | */ |
||
| 2126 | 5 | public function walkStateFieldPathExpression($stateFieldPathExpression) |
|
| 2130 | |||
| 2131 | /** |
||
| 2132 | * {@inheritdoc} |
||
| 2133 | */ |
||
| 2134 | 256 | public function walkComparisonExpression($compExpr) |
|
| 2152 | |||
| 2153 | /** |
||
| 2154 | * {@inheritdoc} |
||
| 2155 | */ |
||
| 2156 | 211 | public function walkInputParameter($inputParam) |
|
| 2168 | |||
| 2169 | /** |
||
| 2170 | * {@inheritdoc} |
||
| 2171 | */ |
||
| 2172 | 322 | public function walkArithmeticExpression($arithmeticExpr) |
|
| 2178 | |||
| 2179 | /** |
||
| 2180 | * {@inheritdoc} |
||
| 2181 | */ |
||
| 2182 | 384 | public function walkSimpleArithmeticExpression($simpleArithmeticExpr) |
|
| 2190 | |||
| 2191 | /** |
||
| 2192 | * {@inheritdoc} |
||
| 2193 | */ |
||
| 2194 | 405 | public function walkArithmeticTerm($term) |
|
| 2210 | |||
| 2211 | /** |
||
| 2212 | * {@inheritdoc} |
||
| 2213 | */ |
||
| 2214 | 405 | public function walkArithmeticFactor($factor) |
|
| 2232 | |||
| 2233 | /** |
||
| 2234 | * Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL. |
||
| 2235 | * |
||
| 2236 | * @param mixed $primary |
||
| 2237 | * |
||
| 2238 | * @return string The SQL. |
||
| 2239 | */ |
||
| 2240 | 405 | public function walkArithmeticPrimary($primary) |
|
| 2252 | |||
| 2253 | /** |
||
| 2254 | * {@inheritdoc} |
||
| 2255 | */ |
||
| 2256 | 18 | public function walkStringPrimary($stringPrimary) |
|
| 2262 | |||
| 2263 | /** |
||
| 2264 | * {@inheritdoc} |
||
| 2265 | */ |
||
| 2266 | 30 | public function walkResultVariable($resultVariable) |
|
| 2276 | |||
| 2277 | /** |
||
| 2278 | * @param ClassMetadataInfo $discrClass |
||
| 2279 | * @param AST\InstanceOfExpression $instanceOfExpr |
||
| 2280 | * @return string The list in parentheses of valid child discriminators from the given class |
||
| 2281 | * @throws QueryException |
||
| 2282 | */ |
||
| 2283 | 12 | private function getChildDiscriminatorsFromClassMetadata(ClassMetadataInfo $discrClass, AST\InstanceOfExpression $instanceOfExpr) |
|
| 2325 | } |
||
| 2326 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.