From 4eac440c56c7ac6620b5b603a71393430237a28b Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 6 Sep 2007 20:38:22 +0000 Subject: [PATCH] --- lib/Doctrine/Collection.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index d9303b559..3d0860885 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -300,7 +300,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator */ public function get($key) { - if ($key === null || ! isset($this->data[$key])) { + if ( ! isset($this->data[$key])) { $record = $this->_table->create(); if (isset($this->referenceField)) { @@ -312,8 +312,11 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator $record->set($this->referenceField, $this->reference, false); } } - - $this->data[] = $record; + if ($key === null) { + $this->data[] = $record; + } else { + $this->data[$key] = $record; + } return $record; }