From c8899c2b3b99883fa9afc36e58eb4cb438dec539 Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Sun, 12 Aug 2012 20:02:01 -0300 Subject: [PATCH] second round of CS fixes --- .../AbstractCollectionPersister.php | 1 + .../ORM/Persisters/BasicEntityPersister.php | 26 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php index 381c6e6fd..d310e91e2 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php @@ -236,6 +236,7 @@ abstract class AbstractCollectionPersister * * @param \Doctrine\ORM\PersistentCollection $coll * @param mixed $index + * * @return object */ public function get(PersistentCollection $coll, $index) diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index 7376a33a3..fe8fe8ed9 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -381,7 +381,6 @@ class BasicEntityPersister $params = array(); foreach ($updateData as $columnName => $value) { - $placeholder = '?'; $column = $columnName; @@ -503,7 +502,7 @@ class BasicEntityPersister if ($selfReferential) { - $otherColumns = ! $mapping['isOwningSide'] + $otherColumns = (! $mapping['isOwningSide']) ? $association['joinTable']['joinColumns'] : $association['joinTable']['inverseJoinColumns']; } @@ -1109,9 +1108,9 @@ class BasicEntityPersister throw ORMException::invalidOrientation($this->class->name, $fieldName); } - $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited']) ? - $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited']) - : $baseTableAlias; + $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited']) + ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited']) + : $baseTableAlias; $columnName = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform); @@ -1197,7 +1196,6 @@ class BasicEntityPersister $joinTableName = $this->quoteStrategy->getTableName($eagerEntity, $this->platform); if ($assoc['isOwningSide']) { - $tableAlias = $this->getSQLTableAlias($association['targetEntity'], $assocAlias); $this->selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($association['joinColumns']); @@ -1309,14 +1307,12 @@ class BasicEntityPersister return $this->insertSql; } - $insertSql = ''; $columns = $this->getInsertColumnList(); + $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); if (empty($columns)) { - $this->insertSql = $this->platform->getEmptyIdentityInsertSQL( - $this->quoteStrategy->getTableName($this->class, $this->platform), - $this->quoteStrategy->getColumnName($this->class->identifier[0], $this->class, $this->platform) - ); + $identityColumn = $this->quoteStrategy->getColumnName($this->class->identifier[0], $this->class, $this->platform); + $this->insertSql = $this->platform->getEmptyIdentityInsertSQL($tableName, $identityColumn); return $this->insertSql; } @@ -1331,15 +1327,17 @@ class BasicEntityPersister && isset($this->columnTypes[$this->class->fieldNames[$column]]) && isset($this->class->fieldMappings[$this->class->fieldNames[$column]]['requireSQLConversion'])) { - $type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]); + $type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]); $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); } $values[] = $placeholder; } - $this->insertSql = 'INSERT INTO ' . $this->quoteStrategy->getTableName($this->class, $this->platform) - . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')'; + $columns = implode(', ', $columns); + $values = implode(', ', $values); + + $this->insertSql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $tableName, $columns, $values); return $this->insertSql; }