Пример #1
0
 /** {@inheritdoc} */
 protected function _getSelectColumnListSQL()
 {
     $columnList = parent::_getSelectColumnListSQL();
     // Append discriminator column
     $discrColumn = $this->_class->discriminatorColumn['name'];
     $columnList .= ", {$discrColumn}";
     $rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
     $tableAlias = $this->_getSQLTableAlias($rootClass->name);
     $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
     $this->_rsm->setDiscriminatorColumn('r', $resultColumnName);
     $this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn);
     // Append subclass columns
     foreach ($this->_class->subClasses as $subClassName) {
         $subClass = $this->_em->getClassMetadata($subClassName);
         // Regular columns
         foreach ($subClass->fieldMappings as $fieldName => $mapping) {
             if (!isset($mapping['inherited'])) {
                 $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
             }
         }
         // Foreign key columns
         foreach ($subClass->associationMappings as $assoc) {
             if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE && !isset($assoc['inherited'])) {
                 foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
                     if ($columnList != '') {
                         $columnList .= ', ';
                     }
                     $columnList .= $this->getSelectJoinColumnSQL($tableAlias, $srcColumn, isset($assoc['inherited']) ? $assoc['inherited'] : $this->_class->name);
                 }
             }
         }
     }
     return $columnList;
 }
 /** {@inheritdoc} */
 protected function _getSelectColumnListSQL()
 {
     $columnList = parent::_getSelectColumnListSQL();
     // Append discriminator column
     $discrColumn = $this->_class->discriminatorColumn['name'];
     $columnList .= ", {$discrColumn}";
     $rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
     $tableAlias = $this->_getSQLTableAlias($rootClass->name);
     $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
     $this->_resultColumnNames[$resultColumnName] = $discrColumn;
     // Append subclass columns
     foreach ($this->_class->subClasses as $subClassName) {
         $subClass = $this->_em->getClassMetadata($subClassName);
         // Regular columns
         foreach ($subClass->fieldMappings as $fieldName => $mapping) {
             if (!isset($mapping['inherited'])) {
                 $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
             }
         }
         // Foreign key columns
         foreach ($subClass->associationMappings as $assoc) {
             if ($assoc->isOwningSide && $assoc->isOneToOne() && !$assoc->inherited) {
                 foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
                     $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
                     $columnList .= ', ' . $tableAlias . ".{$srcColumn} AS {$columnAlias}";
                     $resultColumnName = $this->_platform->getSQLResultCasing($columnAlias);
                     if (!isset($this->_resultColumnNames[$resultColumnName])) {
                         $this->_resultColumnNames[$resultColumnName] = $srcColumn;
                     }
                 }
             }
         }
     }
     return $columnList;
 }