From 33c5012712e70f327f24d75405c6fd69131b17df Mon Sep 17 00:00:00 2001 From: Simon Holywell Date: Thu, 12 Dec 2013 10:23:43 +0000 Subject: [PATCH] Issue #156 findMany() returns only the last record in a set --- README.markdown | 6 ++++++ idiorm.php | 18 +----------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/README.markdown b/README.markdown index fadc25d0..9c9407bf 100644 --- a/README.markdown +++ b/README.markdown @@ -74,6 +74,12 @@ foreach ($tweets as $tweet) { Changelog --------- +#### 1.4.1 - release 2013-12-12 + +**Patch update to remove a broken pull request** - may have consequences for users of 1.4.0 that exploited the "`find_many()` now returns an associative array with the databases primary ID as the array keys" change that was merged in 1.4.0. + +* Back out pull request/issue [#133](https://github.com/j4mie/idiorm/pull/133) as it breaks backwards compatibility in previously unexpected ways (see [#162](https://github.com/j4mie/idiorm/pull/162), [#156](https://github.com/j4mie/idiorm/issues/156) and [#133](https://github.com/j4mie/idiorm/pull/133#issuecomment-29063108) - sorry for merging this change into Idiorm as causing issues. - closes [issue 156](https://github.com/j4mie/idiorm/issues/156) + #### 1.4.0 - release 2013-09-05 * `find_many()` now returns an associative array with the databases primary ID as the array keys [[Surt](https://github.com/Surt)] - [issue #133](https://github.com/j4mie/idiorm/issues/133) diff --git a/idiorm.php b/idiorm.php index dd5cea20..7ac1652a 100644 --- a/idiorm.php +++ b/idiorm.php @@ -611,23 +611,7 @@ public function find_many() { */ protected function _find_many() { $rows = $this->_run(); - return $this->_instances_with_id_as_key($rows); - } - - /** - * Create instances of each row in the result and map - * them to an associative array with the primary IDs as - * the array keys. - * @param array $rows - * @return array - */ - protected function _instances_with_id_as_key($rows) { - $instances = array(); - foreach($rows as $row) { - $row = $this->_create_instance_from_row($row); - $instances[$row->id()] = $row; - } - return $instances; + return array_map(array($this, '_create_instance_from_row'), $rows); } /**