From a1b4b0f73f92b1fc70d9d45cead44aa6f252dd76 Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 1 Oct 2006 15:27:20 +0000 Subject: [PATCH] Simplified object population --- lib/Doctrine/Collection.php | 35 ----------------------------------- lib/Doctrine/Hydrate.php | 13 ------------- 2 files changed, 48 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index 25ec5b2b9..f856796aa 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -520,41 +520,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator return true; } - /** - * populate - * - * @param Doctrine_Query $query - * @param integer $key - */ - public function populate(Doctrine_Hydrate $query) { - $name = $this->table->getComponentName(); - - if($this instanceof Doctrine_Collection_Immediate || - $this instanceof Doctrine_Collection_Offset) { - - $data = $query->getData($name); - if(is_array($data)) { - foreach($data as $k=>$v): - $this->table->setData($v); - $this->add($this->table->getRecord()); - endforeach; - } - } elseif($this instanceof Doctrine_Collection_Batch) { - $this->data = $query->getData($name); - - if(isset($this->keyColumn)) { - foreach($this->data as $k => $v) { - - $value = $record->get($this->keyColumn); - if($value === null) - throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '".$this->keyColumn."' was null."); - - $this->data[$value] = $record; - unset($this->data[$k]); - } - } - } - } /** * loadRelated * diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index 9f1976937..87c2005b0 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -222,20 +222,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { throw new Doctrine_Exception("Unknown fetchmode"); endswitch; - $coll->populate($this); return $coll; } - /** - * getData - * @param $key the component name - * @return array the data row for the specified component - */ - final public function getData($key) { - if(isset($this->data[$key]) && is_array($this->data[$key])) - return $this->data[$key]; - - return array(); - } /** * convertBoolean * converts boolean to integers @@ -255,7 +243,6 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { * @return Doctrine_Collection the root collection */ public function execute($params = array(), $return = Doctrine::FETCH_RECORD) { - $this->data = array(); $this->collections = array(); array_walk($params, array(__CLASS__, 'convertBoolean'));