summaryrefslogtreecommitdiff
path: root/idiorm.php
diff options
context:
space:
mode:
Diffstat (limited to 'idiorm.php')
-rw-r--r--idiorm.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/idiorm.php b/idiorm.php
index a43c767..062ed7f 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -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;
}
/**