diff options
-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; } /** |