From 9a041c8fdbb2ee92e40f00285a52b3c76f56c61c Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Fri, 27 Jul 2012 22:20:49 -0300 Subject: [PATCH] code refactoring on OneToManyPersister --- lib/Doctrine/ORM/Persisters/OneToManyPersister.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php index c88d755b3..100e834cf 100644 --- a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -42,11 +42,13 @@ class OneToManyPersister extends AbstractCollectionPersister */ protected function getDeleteRowSQL(PersistentCollection $coll) { - $mapping = $coll->getMapping(); - $class = $this->em->getClassMetadata($mapping['targetEntity']); + $mapping = $coll->getMapping(); + $class = $this->em->getClassMetadata($mapping['targetEntity']); + $tableName = $this->quoteStrategy->getTableName($class, $this->platform); + $idColumns = $class->getIdentifierColumnNames(); - return 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform) - . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; + return 'DELETE FROM ' . $tableName + . ' WHERE ' . implode('= ? AND ', $idColumns) . ' = ?'; } /** @@ -119,7 +121,8 @@ class OneToManyPersister extends AbstractCollectionPersister $whereClauses = array(); $params = array(); - foreach ($targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] as $joinColumn) { + $joinColumns = $targetClass->associationMappings[$mapping['mappedBy']]['joinColumns']; + foreach ($joinColumns as $joinColumn) { $whereClauses[] = $joinColumn['name'] . ' = ?'; $params[] = ($targetClass->containsForeignIdentifier)