Skip to content

Commit

Permalink
Fix major performance issues caused by unnecessary save() calls
Browse files Browse the repository at this point in the history
closes #12
  • Loading branch information
VanTanev committed Jun 14, 2013
1 parent 7cb5e17 commit ba45a47
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/templates/parent/processEqualNestQueries.php
Expand Up @@ -8,17 +8,20 @@
public function processEqualNestQueries(PropelPDO $con = null)
{
if (false === $this->alreadyInEqualNestProcessing && null !== $this-><?php echo $collName ?>) {
$this->alreadyInEqualNestProcessing = true;

if (null === $con) {
$con = Propel::getConnection(<?php echo $peerClassname ?>::DATABASE_NAME, Propel::CONNECTION_WRITE);
}

$this->alreadyInEqualNestProcessing = true;

$this->clearList<?php echo $pluralRefTableName ?>PKs();
$this->initList<?php echo $pluralRefTableName ?>PKs($con);

$this-><?php echo $collName ?>->save();
foreach ($this-><?php echo $collName ?> as $a<?php echo $refTableName ?>) {
if (!$a<?php echo $refTableName ?>->isDeleted() && ($a<?php echo $refTableName ?>->isNew() || $a<?php echo $refTableName ?>->isModified())) {
$a<?php echo $refTableName ?>->save($con);
}
}

$con->beginTransaction();

Expand All @@ -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;
}
}

0 comments on commit ba45a47

Please sign in to comment.