@@ 1390-1415 (lines=26) @@ | ||
1387 | $sqlParts = []; |
|
1388 | ||
1389 | // Select all fields from the queried class |
|
1390 | foreach ($class->fieldMappings as $fieldName => $mapping) { |
|
1391 | if ($partialFieldSet && ! in_array($fieldName, $partialFieldSet)) { |
|
1392 | continue; |
|
1393 | } |
|
1394 | ||
1395 | $tableName = (isset($mapping['inherited'])) |
|
1396 | ? $this->em->getClassMetadata($mapping['inherited'])->getTableName() |
|
1397 | : $class->getTableName(); |
|
1398 | ||
1399 | $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); |
|
1400 | $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); |
|
1401 | $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); |
|
1402 | ||
1403 | $col = $sqlTableAlias . '.' . $quotedColumnName; |
|
1404 | ||
1405 | if (isset($mapping['requireSQLConversion'])) { |
|
1406 | $type = Type::getType($mapping['type']); |
|
1407 | $col = $type->convertToPHPValueSQL($col, $this->platform); |
|
1408 | } |
|
1409 | ||
1410 | $sqlParts[] = $col . ' AS '. $columnAlias; |
|
1411 | ||
1412 | $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; |
|
1413 | ||
1414 | $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $class->name); |
|
1415 | } |
|
1416 | ||
1417 | // Add any additional fields of subclasses (excluding inherited fields) |
|
1418 | // 1) on Single Table Inheritance: always, since its marginal overhead |
|
@@ 1422-1447 (lines=26) @@ | ||
1419 | // 2) on Class Table Inheritance only if partial objects are disallowed, |
|
1420 | // since it requires outer joining subtables. |
|
1421 | if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { |
|
1422 | foreach ($class->subClasses as $subClassName) { |
|
1423 | $subClass = $this->em->getClassMetadata($subClassName); |
|
1424 | $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); |
|
1425 | ||
1426 | foreach ($subClass->fieldMappings as $fieldName => $mapping) { |
|
1427 | if (isset($mapping['inherited']) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet))) { |
|
1428 | continue; |
|
1429 | } |
|
1430 | ||
1431 | $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); |
|
1432 | $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); |
|
1433 | ||
1434 | $col = $sqlTableAlias . '.' . $quotedColumnName; |
|
1435 | ||
1436 | if (isset($mapping['requireSQLConversion'])) { |
|
1437 | $type = Type::getType($mapping['type']); |
|
1438 | $col = $type->convertToPHPValueSQL($col, $this->platform); |
|
1439 | } |
|
1440 | ||
1441 | $sqlParts[] = $col . ' AS ' . $columnAlias; |
|
1442 | ||
1443 | $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; |
|
1444 | ||
1445 | $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); |
|
1446 | } |
|
1447 | } |
|
1448 | } |
|
1449 | ||
1450 | $sql .= implode(', ', $sqlParts); |