From 60136a4b0a89aaf6599b83bdf8d24c7e3dda2f5f Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 24 May 2007 13:29:18 +0000 Subject: [PATCH] --- lib/Doctrine/Connection/UnitOfWork.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index 05917a582..5806ae7f4 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -142,25 +142,23 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module { $saveLater = array(); foreach ($record->getReferences() as $k => $v) { - $fk = $record->getTable()->getRelation($k); - if ($fk instanceof Doctrine_Relation_ForeignKey || - $fk instanceof Doctrine_Relation_LocalKey) { - $local = $fk->getLocal(); - $foreign = $fk->getForeign(); + $rel = $record->getTable()->getRelation($k); - if ($record->getTable()->hasPrimaryKey($fk->getLocal())) { + if ($rel instanceof Doctrine_Relation_ForeignKey || + $rel instanceof Doctrine_Relation_LocalKey) { + $local = $rel->getLocal(); + $foreign = $rel->getForeign(); + + if ($record->getTable()->hasPrimaryKey($rel->getLocal())) { if ( ! $record->exists()) { - $saveLater[$k] = $fk; + $saveLater[$k] = $rel; } else { $v->save($this->conn); } } else { // ONE-TO-ONE relationship - $obj = $record->get($fk->getAlias()); - - if ($obj->exists()) { - $obj->save($this->conn); - } + $obj = $record->get($rel->getAlias()); + $obj->save($this->conn); } }