From ba45a47aad9dc5a14809f471231d0f06e5916da1 Mon Sep 17 00:00:00 2001 From: IvanTanev Date: Fri, 14 Jun 2013 19:01:41 +0300 Subject: [PATCH] Fix major performance issues caused by unnecessary save() calls closes #12 --- src/templates/parent/processEqualNestQueries.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/templates/parent/processEqualNestQueries.php b/src/templates/parent/processEqualNestQueries.php index 908873a..37d3766 100644 --- a/src/templates/parent/processEqualNestQueries.php +++ b/src/templates/parent/processEqualNestQueries.php @@ -8,17 +8,20 @@ public function processEqualNestQueries(PropelPDO $con = null) { if (false === $this->alreadyInEqualNestProcessing && null !== $this->) { + $this->alreadyInEqualNestProcessing = true; if (null === $con) { $con = Propel::getConnection(::DATABASE_NAME, Propel::CONNECTION_WRITE); } - $this->alreadyInEqualNestProcessing = true; - $this->clearListPKs(); $this->initListPKs($con); - $this->->save(); + foreach ($this-> as $a) { + if (!$a->isDeleted() && ($a->isNew() || $a->isModified())) { + $a->save($con); + } + } $con->beginTransaction(); @@ -41,10 +44,11 @@ public function processEqualNestQueries(PropelPDO $con = null) } $con->commit(); - $this->alreadyInEqualNestProcessing = false; } catch (PropelException $e) { $con->rollBack(); throw $e; } + + $this->alreadyInEqualNestProcessing = false; } }