当前位置: 首页>>代码示例>>PHP>>正文


PHP Books::model方法代码示例

本文整理汇总了PHP中Books::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Books::model方法的具体用法?PHP Books::model怎么用?PHP Books::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Books的用法示例。


在下文中一共展示了Books::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRemove

 public function actionRemove($b_id)
 {
     Yii::app()->db->createCommand()->delete('lt_books_authors', 'book_id=' . $b_id);
     //removing records from link table
     Books::model()->deleteByPk($b_id);
     $this->actionIndex();
 }
开发者ID:alex-sparrow,项目名称:library_test,代码行数:7,代码来源:BooksController.php

示例2: actionIndex

 public function actionIndex()
 {
     $book_model = Books::model();
     $authors_model = Authors::model();
     $params = array('book_model' => $book_model, 'authors_model' => $authors_model);
     $this->render('report', $params);
 }
开发者ID:maxim-bondarenko,项目名称:library,代码行数:7,代码来源:ReportsController.php

示例3: getBooksFromFiltr

 private function getBooksFromFiltr($arg)
 {
     //прием аргументов фильтрации, снова повторюсь сори что без валидации
     $authors = $arg['authors'];
     $genre = $arg['genre'];
     $from_year = $arg['from_year'];
     $to_year = $arg['to_year'];
     //все индификаторы книг что прошли фильтр по автору и по жанрам
     $book_author = BookAuthor::model()->with('books')->findAllByAttributes($authors);
     $book_gerne = BookGenre::model()->with('books')->findAllByAttributes($genre);
     foreach ($book_author as $class) {
         $flag[$class->bid] = true;
         //методом флажок - выясню есть ли в другом масиве теже bid
     }
     foreach ($book_gerne as $class) {
         if ($flag[$class->bid]) {
             $bids[] = $class->bid;
         }
         //если была создана ячека флажка, то значит что первый фильтр bid прошел
     }
     //выборка всех книг по фильтрованым индификаторам
     $books = Books::model()->findAllByAttributes(array('bid' => $bids), 'year>=' . $from_year . ' AND year<=' . $to_year);
     //хочу свормировать красивый масив без ячеек, которые сотворил yii
     $result = array();
     $i = 0;
     foreach ($books as $book) {
         $result[$i]['authors'] = $this->getAuthorsFromBid($book->bid);
         $result[$i]['genres'] = $this->getGenresFromBid($book->bid);
         $result[$i]['book']['bid'] = $book->bid;
         $result[$i]['book']['name'] = $book->name;
         $result[$i]['book']['year'] = $book->year;
         $i = $i + 1;
     }
     return $result;
 }
开发者ID:xtarantulz,项目名称:books_yii,代码行数:35,代码来源:BooksController.php

示例4: actionSearch

 public function actionSearch()
 {
     $model = Books::model();
     $params = array('result' => $model->searchPhrase($_POST['search_field']));
     $this->render('search', $params);
     //echo '<pre>'; print_r($_POST); echo'</pre>';
 }
开发者ID:maxim-bondarenko,项目名称:library,代码行数:7,代码来源:SearchController.php

示例5: actionAbout

 public function actionAbout($id)
 {
     $book = Books::model()->findByPk($id);
     if (!empty($book)) {
         $comments = BooksComments::model()->findAll(array('condition' => 'book_id = :bookId', 'params' => array(':bookId' => $book->id), 'order' => 'id DESC', 'limit' => '10'));
         $this->render('about', array('book' => $book, 'comments' => $comments));
     } else {
         $this->redirect(array('index/index'));
     }
 }
开发者ID:vetalded,项目名称:homelibrary16mbcom,代码行数:10,代码来源:BookInfoController.php

示例6: loadModel

 public function loadModel($id = null, $new = false)
 {
     if ($this->_book === null) {
         if ($new) {
             return $this->_book = new Books();
         }
         $this->_book = Books::model()->findByPk($_GET['id']);
         if ($this->_book === null) {
             throw new CHttpException(404, 'Sorry! There is no such book.');
         }
     }
     return $this->_book;
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:13,代码来源:BooksController.php

示例7: setBookRate

 /**
  * @property  Books $book
  */
 public static function setBookRate($id, $percent)
 {
     $percent = $percent > 100 ? 100 : $percent < 0 ? 0 : $percent;
     $rate = self::model()->findByAttributes(array('book_id' => $id, 'user_id' => Yii::app()->user->id));
     if (empty($rate)) {
         $rate = new BookRate();
         $rate->book_id = $id;
         $rate->user_id = Yii::app()->user->id;
     }
     $rate->rate = $percent;
     $rate->save();
     $book = Books::model()->findByPk($id);
     if (!empty($book)) {
         $book->updateRate();
     }
     return $book->rate;
 }
开发者ID:vetalded,项目名称:homelibrary16mbcom,代码行数:20,代码来源:BookRate.php

示例8: loadModel

 /**
  * 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 Books the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Books::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:vlad-doroshchuk,项目名称:testwork1,代码行数:15,代码来源:BooksController.php

示例9: actionIndex

 public function actionIndex()
 {
     $books = Books::model()->findAll(array('order' => 'RAND()', 'limit' => 10));
     $this->render("index", array('books' => $books));
 }
开发者ID:vetalded,项目名称:homelibrary16mbcom,代码行数:5,代码来源:IndexController.php

示例10: detailBook

 public function detailBook($book_id)
 {
     $data = Books::model()->findByAttributes(array('id' => $book_id));
     return $data;
 }
开发者ID:huynt57,项目名称:books,代码行数:5,代码来源:Books.php

示例11: actionUpdateLibraryData

 public function actionUpdateLibraryData($id)
 {
     $params = $_POST['ReadersBooksRelation'];
     $book_id = $_POST['books_list'];
     $params['book_id'] = $book_id;
     $params['reader_id'] = $_POST['reader_list'];
     $model = new ReadersBooksRelation();
     $last_count = ($res = $model->getDataRelationById($id)) ? (int) $params['count_books'] - (int) $res->count_books : $params['count_books'];
     $free_book = Books::model()->isFreeBook($book_id, $last_count);
     $message = '';
     $color = '';
     if (!$free_book) {
         $message = 'Все экземпляры книги находятся у читателей!!!';
         $color = TbHtml::ALERT_COLOR_WARNING;
     } else {
         $model->deleteByPk($id);
         $model->attributes = $params;
         if ($model->validate()) {
             if ($model->save()) {
                 $message = 'Обновление Прошло успешно';
                 $color = TbHtml::ALERT_COLOR_SUCCESS;
             }
         }
     }
     Yii::app()->user->setFlash($color, $message);
     $this->redirect(array('library/tabs&tab_id=library'));
 }
开发者ID:maxim-bondarenko,项目名称:library,代码行数:27,代码来源:LibraryController.php

示例12: actionSearch

 public function actionSearch()
 {
     $request = Yii::app()->request;
     try {
         $query = $request->getQuery('query');
         $limit = $request->getQuery('limit');
         $offset = $request->getQuery('offset');
         $data = Books::model()->searchBooks($query, $limit, $offset);
         ResponseHelper::JsonReturnSuccess($data, "Success");
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:meboo_nhaplieu,代码行数:13,代码来源:BookController.php


注:本文中的Books::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。