1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Simplified object population

This commit is contained in:
zYne 2006-10-01 15:27:20 +00:00
parent 5de6c0a65b
commit a1b4b0f73f
2 changed files with 0 additions and 48 deletions

View File

@ -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
*

View File

@ -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'));