From 753e9bd4cc66610ff14defb6661da8af9304c182 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 27 Sep 2006 21:54:00 +0000 Subject: [PATCH] Fixes #131 Ticket: 131 --- lib/Doctrine/Collection.php | 2 +- lib/Doctrine/Hydrate.php | 4 +++- lib/Doctrine/Record.php | 16 +++------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index e638ffa68..058d262d8 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -96,7 +96,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator * getTable * returns the table this collection belongs to * - * @return object Doctrine_Table + * @return Doctrine_Table */ public function getTable() { return $this->table; diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index 280b6d353..d1f08942f 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -417,7 +417,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { if($fk instanceof Doctrine_LocalKey) $last->set($fk->getLocal(), $record->getIncremented(), false); - $last->initSingleReference($record, $fk); + $last->set($fk->getAlias(), $record); $prev[$name] = $record; break; @@ -428,6 +428,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { if( ! $last->hasReference($alias)) { $prev[$name] = $this->getCollection($name); $last->initReference($prev[$name], $fk); + + //$last->set($fk->getAlias(), $this->getCollection($name)); } else { // previous entry found from identityMap $prev[$name] = $last->get($alias); diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index feac54df1..21247f2ae 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -741,6 +741,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } catch(Doctrine_Table_Exception $e) { throw new Doctrine_Record_Exception("Unknown property / related component '$name'."); } + + // one-to-many or one-to-one relation if($rel instanceof Doctrine_ForeignKey || $rel instanceof Doctrine_LocalKey) { @@ -760,7 +762,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references."); if($rel->getLocal() == $this->table->getIdentifier()) { - $this->references[$name]->set($rel->getForeign(),$this); + $value->set($rel->getForeign(), $this, false); } else { $this->set($rel->getLocal(),$value); } @@ -1151,18 +1153,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite throw new Doctrine_Record_Exception("Unknown reference $name"); } - /** - * initalizes a one-to-one relation - * - * @param Doctrine_Record $record - * @param Doctrine_Relation $connector - * @return void - */ - public function initSingleReference(Doctrine_Record $record, Doctrine_Relation $connector) { - $alias = $connector->getAlias(); - - $this->references[$alias] = $record; - } /** * initalizes a one-to-many / many-to-many relation *