parent
1a0179bdce
commit
ddf0ceab82
@ -487,38 +487,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
|
||||
$this->data[$key] = $record;
|
||||
}
|
||||
/**
|
||||
* adds a record to collection
|
||||
* @param Doctrine_Record $record record to be added
|
||||
* @param string $key optional key for the record
|
||||
* @return boolean
|
||||
*/
|
||||
public function internalAdd(Doctrine_Record $record,$key = null) {
|
||||
if(in_array($record,$this->data))
|
||||
return false;
|
||||
|
||||
if(isset($this->reference_field))
|
||||
$record->set($this->reference_field, $this->reference, false);
|
||||
|
||||
if(isset($key)) {
|
||||
if(isset($this->data[$key]))
|
||||
return false;
|
||||
|
||||
$this->data[$key] = $record;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($this->keyColumn)) {
|
||||
$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;
|
||||
} else
|
||||
$this->data[] = $record;
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* adds a record to collection
|
||||
* @param Doctrine_Record $record record to be added
|
||||
|
@ -1188,8 +1188,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
public function addReference(Doctrine_Record $record, Doctrine_Relation $connector, $key = null) {
|
||||
$alias = $connector->getAlias();
|
||||
|
||||
$this->references[$alias]->internalAdd($record, $key);
|
||||
$this->originals[$alias]->internalAdd($record, $key);
|
||||
$this->references[$alias]->add($record, $key);
|
||||
$this->originals[$alias]->add($record, $key);
|
||||
}
|
||||
/**
|
||||
* getReferences
|
||||
|
Loading…
Reference in New Issue
Block a user