function getAllBook() { $key = 'book'; $collection = CacheManager::get($key, TRUE); if ($collection) { return $collection; } $collection = new Collection(); $this->connect(); $result = $this->conn->query("CALL sp_get_all_book()"); if ($result) { //$row = $result->fetch_assoc(); while ($obj = $result->fetch_object()) { $book = new Book(); $book->setBookId($obj->Book_id); $book->setTitle($obj->Title); $book->setPublisherId($obj->Publisher_id); $book->setIsbn($obj->Isbn); $book->setCategoryId($obj->Category_id); $book->setPublisherName($obj->Publisher_name); $book->setCategoryName($obj->Subject); $collection->addItem($book, $obj->Book_id); } $result->close(); // for fetch_object() } //$result->free_result(); // for fetch_assoc() $this->close(); CacheManager::set($key, $collection, TRUE); return $collection; }