Esempio n. 1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return BookCopy the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = BookCopy::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 function getAllBookCopy()
 {
     $key = 'copy';
     $collection = CacheManager::get($key, TRUE);
     if ($collection) {
         return $collection;
     }
     $collection = new Collection();
     $this->connect();
     $result = $this->conn->query("CALL sp_get_all_book_copy()");
     if ($result) {
         //$row = $result->fetch_assoc();
         while ($obj = $result->fetch_object()) {
             $bookCopy = new BookCopy();
             $bookCopy->setBarcodeId($obj->Barcode_id);
             $bookCopy->setBookId($obj->Book_id);
             $bookCopy->setStockDate($obj->Stock_date);
             $bookCopy->setLogId($obj->Log_id);
             $bookCopy->setTitle($obj->Title);
             $collection->addItem($bookCopy, $obj->Barcode_id);
         }
         $result->close();
         // for fetch_object()
     }
     //$result->free_result(); // for fetch_assoc()
     $this->close();
     CacheManager::set($key, $collection, TRUE);
     return $collection;
 }