1
0
mirror of synced 2025-03-16 21:21:50 +03:00

Substitute array_diff function with array_udiff to allow overriding __toString()

This commit is contained in:
jackbravo 2007-09-10 16:16:24 +00:00
parent 0436fc8e96
commit d8352d67fa

View File

@ -577,7 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
public function processDiff()
{
foreach (array_diff($this->_snapshot, $this->data) as $record) {
foreach (array_udiff($this->_snapshot, $this->data, array($this, "compareRecords")) as $record) {
$record->delete();
}
@ -605,11 +605,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
public function getDeleteDiff()
{
return array_diff($this->_snapshot, $this->data);
return array_udiff($this->_snapshot, $this->data, array($this, "compareRecords"));
}
public function getInsertDiff()
{
return array_diff($this->data, $this->_snapshot);
return array_udiff($this->data, $this->_snapshot, array($this, "compareRecords"));
}
/**
* compareRecords
* Compares two records. To be used on _snapshot diffs using array_udiff
*/
protected function compareRecords($a, $b)
{
if ($a->getOid() == $b->getOid()) return 0;
return ($a->getOid() > $b->getOid()) ? 1 : -1;
}
/**
* save