1
0
mirror of synced 2025-03-28 02:43:55 +03:00

Added fromArray() methods.

This commit is contained in:
Jonathan.Wage 2007-09-21 21:40:54 +00:00
parent b574c7209e
commit 5aa73029cf
2 changed files with 22 additions and 0 deletions

View File

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

View File

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