Skip to content

Commit

Permalink
Issue #156 findMany() returns only the last record in a set
Browse files Browse the repository at this point in the history
  • Loading branch information
treffynnon committed Dec 12, 2013
1 parent 3be516b commit 33c5012
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 1 addition & 17 deletions idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 33c5012

Please sign in to comment.