Added fromArray() methods.
This commit is contained in:
parent
b574c7209e
commit
5aa73029cf
@ -603,6 +603,18 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
public function fromArray($array)
|
||||
{
|
||||
$data = array();
|
||||
foreach ($array as $key => $row) {
|
||||
$record = $this->_table->getRecord();
|
||||
$record->fromArray($row);
|
||||
|
||||
$data[$key] = $record;
|
||||
}
|
||||
|
||||
$this->data = $data;
|
||||
}
|
||||
public function getDeleteDiff()
|
||||
{
|
||||
return array_udiff($this->_snapshot, $this->data, array($this, "compareRecords"));
|
||||
|
@ -1139,6 +1139,16 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
||||
}
|
||||
return array_merge($a, $this->_values);
|
||||
}
|
||||
public function fromArray($array)
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (!$this->getTable()->hasRelation($key) && $this->getTable()->hasColumn($key)) {
|
||||
$this->$key = $value;
|
||||
} else {
|
||||
$this->$key->fromArray($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* exists
|
||||
* returns true if this record is persistent, otherwise false
|
||||
|
Loading…
x
Reference in New Issue
Block a user