function getAllCategory() { $key = 'category'; $collection = CacheManager::get($key, TRUE); if ($collection) { return $collection; } $collection = new Collection(); $this->connect(); $result = $this->conn->query("CALL sp_get_all_category()"); if ($result) { //$row = $result->fetch_assoc(); while ($obj = $result->fetch_object()) { $category = new Category(); $category->setId($obj->Category_id); $category->setSubject($obj->Subject); $category->setParentId($obj->Parent_id); $category->setSectionId($obj->Section_id); $category->setParentSubject($obj->Parent_subject); $category->setSectionName($obj->Section_name); $collection->addItem($category, $obj->Category_id); } $result->close(); // for fetch_object() } //$result->free_result(); // for fetch_assoc() $this->close(); CacheManager::set($key, $collection, TRUE); return $collection; }