From 15317cf053f2d9fbb7d7454a7ad79663bf9f6b14 Mon Sep 17 00:00:00 2001 From: vstaikov Date: Wed, 20 Jun 2018 11:31:22 +0300 Subject: [PATCH] Keep objects mapped A fix for the objects mapping. --- dbObject.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbObject.php b/dbObject.php index dbf39d89..94d70eb1 100644 --- a/dbObject.php +++ b/dbObject.php @@ -385,14 +385,14 @@ protected function get ($limit = null, $fields = null) { if ($this->db->count == 0) return null; - foreach ($results as &$r) { + foreach ($results as $k => &$r) { $this->processArrays ($r); $this->data = $r; $this->processAllWith ($r, false); if ($this->returnType == 'Object') { $item = new static ($r); $item->isNew = false; - $objects[] = $item; + $objects[$k] = $item; } } $this->_with = Array(); @@ -476,14 +476,14 @@ private function paginate ($page, $fields = null) { self::$totalPages = $this->db->totalPages; if ($this->db->count == 0) return null; - foreach ($res as &$r) { + foreach ($res as $k => &$r) { $this->processArrays ($r); $this->data = $r; $this->processAllWith ($r, false); if ($this->returnType == 'Object') { $item = new static ($r); $item->isNew = false; - $objects[] = $item; + $objects[$k] = $item; } } $this->_with = Array();