diff options
author | Erik Wiesenthal <[email protected]> | 2013-08-30 10:46:27 +0100 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2013-08-30 10:46:27 +0100 |
commit | 022d328fcd82755d07b702f07a1fb03e348278bf (patch) | |
tree | ae3e953d738076e464e3fe0959e79bd50f823150 | |
parent | bd82ffdc63883ca24b85ad01e2a60491d6bb48a4 (diff) |
Issue #133 find_many returns an associative array
-rw-r--r-- | idiorm.php | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -611,7 +611,23 @@ */ protected function _find_many() { $rows = $this->_run(); - return array_map(array($this, '_create_instance_from_row'), $rows); + 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 _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; } /** |