Commit 5aa73029 authored by Jonathan.Wage's avatar Jonathan.Wage

Added fromArray() methods.

parent b574c720
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment