diff --git a/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php index da50b3be8..425da798a 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php @@ -28,24 +28,11 @@ use Doctrine\ORM\Mapping\ClassMetadata, * types in the hierarchy. * * @author Roman Borschel + * @author Benjamin Eberlei * @since 2.0 */ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister { - /** - * Map from column names to class metadata instances that declare the field the column is mapped to. - * - * @var array - */ - private $declaringClassMap = array(); - - /** - * Map from column names to class names that declare the field the association with join column is mapped to. - * - * @var array - */ - private $declaringJoinColumnMap = array(); - /** * {@inheritdoc} */ @@ -66,40 +53,6 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister */ abstract protected function _getDiscriminatorColumnTableName(); - /** - * {@inheritdoc} - */ - protected function _processSQLResult(array $sqlResult) - { - $data = array(); - $discrColumnName = $this->_platform->getSQLResultCasing($this->_class->discriminatorColumn['name']); - $entityName = $this->_class->discriminatorMap[$sqlResult[$discrColumnName]]; - unset($sqlResult[$discrColumnName]); - foreach ($sqlResult as $column => $value) { - $realColumnName = $this->_resultColumnNames[$column]; - if (isset($this->declaringClassMap[$column])) { - $class = $this->declaringClassMap[$column]; - if ($class->name == $entityName || is_subclass_of($entityName, $class->name)) { - $field = $class->fieldNames[$realColumnName]; - if (isset($data[$field])) { - $data[$realColumnName] = $value; - } else { - $data[$field] = Type::getType($class->fieldMappings[$field]['type']) - ->convertToPHPValue($value, $this->_platform); - } - } - } else if (isset($this->declaringJoinColumnMap[$column])) { - if ($this->declaringJoinColumnMap[$column] == $entityName || is_subclass_of($entityName, $this->declaringJoinColumnMap[$column])) { - $data[$realColumnName] = $value; - } - } else { - $data[$realColumnName] = $value; - } - } - - return array($entityName, $data); - } - /** * {@inheritdoc} */ @@ -108,10 +61,6 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister $columnName = $class->columnNames[$field]; $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $class->getQuotedColumnName($field, $this->_platform); $columnAlias = $this->_platform->getSQLResultCasing($columnName . $this->_sqlAliasCounter++); - if ( ! isset($this->_resultColumnNames[$columnAlias])) { - $this->_resultColumnNames[$columnAlias] = $columnName; - $this->declaringClassMap[$columnAlias] = $class; - } $this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name); return "$sql AS $columnAlias"; @@ -121,10 +70,6 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister { $columnAlias = $joinColumnName . $this->_sqlAliasCounter++; $resultColumnName = $this->_platform->getSQLResultCasing($columnAlias); - if ( ! isset($this->_resultColumnNames[$resultColumnName])) { - $this->_resultColumnNames[$resultColumnName] = $joinColumnName; - $this->declaringJoinColumnMap[$resultColumnName] = $className; - } $this->_rsm->addMetaResult('r', $resultColumnName, $joinColumnName); return $tableAlias . ".$joinColumnName AS $columnAlias"; diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index 6ee526ca9..016184679 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -70,6 +70,7 @@ use PDO, * * @author Roman Borschel * @author Giorgio Sironi + * @author Benjamin Eberlei * @since 2.0 */ class BasicEntityPersister @@ -108,15 +109,6 @@ class BasicEntityPersister * @var array */ protected $_queuedInserts = array(); - - /** - * Case-sensitive mappings of column names as they appear in an SQL result set - * to column names as they are defined in the mapping. This is necessary because different - * RDBMS vendors return column names in result sets in different casings. - * - * @var array - */ - protected $_resultColumnNames = array(); /** * ResultSetMapping that is used for all queries. Is generated lazily once per request. @@ -821,72 +813,6 @@ class BasicEntityPersister return $this->_conn->executeQuery($sql, $params, $types); } - /** - * Creates or fills a single entity object from an SQL result. - * - * @param $result The SQL result. - * @param object $entity The entity object to fill, if any. - * @param array $hints Hints for entity creation. - * @return object The filled and managed entity object or NULL, if the SQL result is empty. - */ - private function _createEntity($result, $entity = null, array $hints = array()) - { - if ($result === false) { - return null; - } - - list($entityName, $data) = $this->_processSQLResult($result); - - if ($entity !== null) { - $hints[Query::HINT_REFRESH] = true; - $id = array(); - if ($this->_class->isIdentifierComposite) { - foreach ($this->_class->identifier as $fieldName) { - $id[$fieldName] = $data[$fieldName]; - } - } else { - $id = array($this->_class->identifier[0] => $data[$this->_class->identifier[0]]); - } - $this->_em->getUnitOfWork()->registerManaged($entity, $id, $data); - } - - return $this->_em->getUnitOfWork()->createEntity($entityName, $data, $hints); - } - - /** - * Processes an SQL result set row that contains data for an entity of the type - * this persister is responsible for. - * - * Subclasses are supposed to override this method if they need to change the - * hydration procedure for entities loaded through basic find operations or - * lazy-loading (not DQL). - * - * @param array $sqlResult The SQL result set row to process. - * @return array A tuple where the first value is the actual type of the entity and - * the second value the prepared data of the entity (a map from field - * names to values). - */ - protected function _processSQLResult(array $sqlResult) - { - $data = array(); - foreach ($sqlResult as $column => $value) { - $column = $this->_resultColumnNames[$column]; - if (isset($this->_class->fieldNames[$column])) { - $field = $this->_class->fieldNames[$column]; - if (isset($data[$field])) { - $data[$column] = $value; - } else { - $data[$field] = Type::getType($this->_class->fieldMappings[$field]['type']) - ->convertToPHPValue($value, $this->_platform); - } - } else { - $data[$column] = $value; - } - } - - return array($this->_class->name, $data); - } - /** * Gets the SELECT SQL to select one or more entities by a set of field criteria. * @@ -1047,9 +973,6 @@ class BasicEntityPersister $columnAlias = $srcColumn . $this->_sqlAliasCounter++; $columnList .= $this->_getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) ) . ".$srcColumn AS $columnAlias"; $resultColumnName = $this->_platform->getSQLResultCasing($columnAlias); - if ( ! isset($this->_resultColumnNames[$resultColumnName])) { - $this->_resultColumnNames[$resultColumnName] = $srcColumn; - } $this->_rsm->addMetaResult($alias, $this->_platform->getSQLResultCasing($columnAlias), $srcColumn); } } @@ -1165,9 +1088,6 @@ class BasicEntityPersister $columnName = $class->columnNames[$field]; $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $class->getQuotedColumnName($field, $this->_platform); $columnAlias = $this->_platform->getSQLResultCasing($columnName . $this->_sqlAliasCounter++); - if ( ! isset($this->_resultColumnNames[$columnAlias])) { - $this->_resultColumnNames[$columnAlias] = $columnName; - } $this->_rsm->addFieldResult($alias, $columnAlias, $field); return "$sql AS $columnAlias"; diff --git a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php index 918f7e1ef..2490085cf 100644 --- a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php @@ -29,6 +29,7 @@ use Doctrine\ORM\ORMException, * database as it is defined by the Class Table Inheritance strategy. * * @author Roman Borschel + * @author Benjamin Eberlei * @since 2.0 * @see http://martinfowler.com/eaaCatalog/classTableInheritance.html */ @@ -283,7 +284,6 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister } $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn); - $this->_resultColumnNames[$resultColumnName] = $discrColumn; $this->_rsm->setDiscriminatorColumn('r', $discrColumn); $this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn); } diff --git a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php index 94450fd89..bf9104580 100644 --- a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php @@ -26,6 +26,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; * SINGLE_TABLE strategy. * * @author Roman Borschel + * @author Benjamin Eberlei * @since 2.0 * @link http://martinfowler.com/eaaCatalog/singleTableInheritance.html */ @@ -48,7 +49,6 @@ class SingleTablePersister extends AbstractEntityInheritancePersister $rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName); $tableAlias = $this->_getSQLTableAlias($rootClass->name); $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn); - $this->_resultColumnNames[$resultColumnName] = $discrColumn; $this->_rsm->setDiscriminatorColumn('r', $discrColumn); $this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn);