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();