• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Books类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

 public function create()
 {
     $userid = Auth::user()->userid;
     // return Input::get("");exit();
     $book = new Books();
     $book->title = Input::get('title');
     $book->description = Input::get('description');
     $book->category = Input::get('genre');
     $book->sub_category = "none";
     $book->author = Input::get('author');
     $book->condition = Input::get('cond');
     $book->location = Input::get('loc');
     $book->cover = Input::get('image');
     $book->snippet = "none";
     $book->language = Input::get('lang');
     $book->popularity = "none";
     $book->quantity = Input::get('quantity');
     $book->expected_price = Input::get('rate');
     $book->purpose = Input::get('purpose');
     $book->added_by = $userid;
     //The USERID
     $book->save();
     //Add Book to Personal Info of the User
     $tn = $userid . "_books";
     DB::table($tn)->insert(array('title' => Input::get('title'), 'author' => Input::get("author"), 'condition' => Input::get('cond'), 'location' => Input::get('loc'), 'language' => Input::get('lang'), 'quantity' => Input::get('quantity'), 'expected_price' => Input::get('rate'), 'avlb' => 1));
 }
开发者ID:zurez,项目名称:rentkardo,代码行数:26,代码来源:BookController.php


示例2: actionAdd

 public function actionAdd()
 {
     Yii::app()->getClientScript()->registerCoreScript('jquery');
     Yii::app()->getClientScript()->registerCoreScript('jquery.ui');
     $cs = Yii::app()->clientScript;
     $cs->registerCssFile('/js/datepicker/css/' . 'datepicker.css');
     $cs->registerScriptFile('/js/' . 'books.js');
     //
     $book = new Books();
     $command = Yii::app()->db->createCommand();
     if (isset($_POST['Books'])) {
         $book->attributes = $_POST['Books'];
         if ($book->validate()) {
             $book->save();
             if (isset($_POST['add_auth']) && !empty($_POST['add_auth'])) {
                 $criteria = new CDbCriteria();
                 $criteria->compare('lastname', $_POST['add_auth']);
                 $add_author = Authors::model()->find($criteria);
                 //If author exists
                 if (!empty($add_author)) {
                     //insert link book-author to link table
                     $command->insert('lt_books_authors', array('author_id' => $add_author->id, 'book_id' => $book->id));
                 }
             }
             $this->actionIndex();
             return true;
         }
     }
     $this->render('edit', array('model' => $book));
 }
开发者ID:alex-sparrow,项目名称:library_test,代码行数:30,代码来源:BooksController.php


示例3: showBook

 function showBook()
 {
     $model = new Books();
     $comment_section = new CommentsController();
     $data = $model->getBookData();
     include 'view/libro/libro.php';
     $comment_section->showComments();
 }
开发者ID:apexJCL,项目名称:mvc,代码行数:8,代码来源:book.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: getOne

	function getOne() {
		$query = 'SELECT * FROM `genre` WHERE `name`=' . Database::escape($this->genre_name);
		$data = Database::sql2row($query);
		if (!isset($data['name']))
			return;
		$this->data['genres'][$data['id']] = array(
		    'name' => $data['name'],
		    'id' => $data['id'],
		    'id_parent' => $data['id_parent'],
		    'title' => $data['title'],
		    'books_count' => $data['books_count']
		);

		if (!$data['id_parent']) {
			$this->data['genres'][$data['id']]['subgenres'] = $this->getAll($data['id']);
			return;
		}

		$query = 'SELECT `id_book` FROM `book_genre` BG JOIN `book` B ON B.id = BG.id_book WHERE BG.id_genre = ' . $data['id'] . ' ORDER BY B.mark DESC LIMIT 20';
		$bids = Database::sql2array($query, 'id_book');
		$books = Books::getByIdsLoaded(array_keys($bids));
		Books::LoadBookPersons(array_keys($bids));

		foreach ($books as $book) {
			$book = Books::getById($book->id);
			list($aid, $aname) = $book->getAuthor(1, 1, 1); // именно наш автор, если их там много
			$this->data['genres'][$data['id']]['books'][] = array('id' => $book->id,
			    'cover' => $book->getCover(),
			    'title' => $book->getTitle(true),
			    'author' => $aname,
			    'author_id' => $aid,
			    'lastSave' => $book->data['modify_time']);
		}
	}
开发者ID:rasstroen,项目名称:diary,代码行数:34,代码来源:genres_module.php


示例6: run

 public function run()
 {
     DB::table('books')->delete();
     Books::create(array('bname' => 'talha', 'bauthor' => 'talha1', 'bedition' => 'Eight', 'p_url' => 'ajed5hrgt4y', 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
     DB::table('books')->insert(['bname' => 'talha', 'bauthor' => 'talha2', 'bedition' => 'ten', 'p_url' => 'ajed53y56hy', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
     DB::table('books')->insert(['bname' => 'talha', 'bauthor' => 'talha3', 'bedition' => 'nine', 'p_url' => 'ajed5hy', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
 }
开发者ID:pnagaraju25,项目名称:larvelCrudFinal,代码行数:7,代码来源:BookTableSeeder.php


示例7: 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


示例8: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $student = Student::find($id);
     if ($student == NULL) {
         throw new Exception('Invalid Student ID');
     }
     $student->year = (int) substr($student->year, 2, 4);
     $student_category = StudentCategories::find($student->category);
     $student->category = $student_category->category;
     $student_branch = Branch::find($student->branch);
     $student->branch = $student_branch->branch;
     if ($student->rejected == 1) {
         unset($student->approved);
         unset($student->books_issued);
         $student->rejected = (bool) $student->rejected;
         return $student;
     }
     if ($student->approved == 0) {
         unset($student->rejected);
         unset($student->books_issued);
         $student->approved = (bool) $student->approved;
         return $student;
     }
     unset($student->rejected);
     unset($student->approved);
     $student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get();
     foreach ($student_issued_books as $issued_book) {
         $issue = Issue::find($issued_book->book_issue_id);
         $book = Books::find($issue->book_id);
         $issued_book->name = $book->title;
         $issued_book->issued_at = date('d-M', $issued_book->issued_at);
     }
     $student->issued_books = $student_issued_books;
     return $student;
 }
开发者ID:linpar,项目名称:library-management-system,代码行数:41,代码来源:StudentController.php


示例9: getRoutes

 static function getRoutes()
 {
     $routes = [['get:books', function () {
         return (new Books())->index();
     }], ['get:books\\/(?<id>\\d+)', function ($params) {
         return (new Books())->show($params['id']);
     }], ['post:books', function () {
         return (new Books())->store(Books::filterData($_REQUEST));
     }], ['put:books\\/(?<id>\\d+)', function ($params) {
         return (new Books())->update($params['id'], Books::filterData($_REQUEST));
     }], ['delete:books\\/(?<id>\\d+)', function ($params) {
         return (new Books())->destroy($params['id']);
     }], ['get:libs', function () {
         return (new Libraries())->index();
     }], ['get:libs\\/(?<id>\\d+)', function ($params) {
         return (new Libraries())->show($params['id']);
     }], ['post:libs', function () {
         return (new Libraries())->store(Libraries::filterData($_REQUEST));
     }], ['put:libs\\/(?<id>\\d+)', function ($params) {
         return (new Libraries())->update($params['id'], Libraries::filterData($_REQUEST));
     }], ['delete:libs\\/(?<id>\\d+)', function ($params) {
         return (new Libraries())->destroy($params['id']);
     }]];
     return $routes;
 }
开发者ID:acidron,项目名称:kpi_bookshelf,代码行数:25,代码来源:routes.php


示例10: commitEdit

 public function commitEdit()
 {
     $id = Input::get('id');
     // validate the info, create rules for the inputs
     $rules = array('title' => 'required', 'author' => 'required');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('edit/' . $id)->withErrors($validator)->withInput();
         // send back the input (not the password) so that we can repopulate the form
     } else {
         //return 'book added';
         // create our user data for the authentication
         $bookdata = array('title' => Input::get('title'), 'author' => Input::get('author'));
         //return $id;
         // update the data
         if ($Book = Books::where('id', '=', $id)->update($bookdata)) {
             // update successful!
             return Redirect::to('books')->with('message', 'Book info updated');
         } else {
             // validation not successful, send back to form
             return Redirect::to('edit/' . $id)->with('message', 'Book info editing failed');
         }
     }
 }
开发者ID:nowshad-sust,项目名称:book_library,代码行数:26,代码来源:LibraryController.php


示例11: actionSearch

 public function actionSearch()
 {
     if (!isset($_GET['val'])) {
         $_GET['val'] = NULL;
     }
     echo Books::getList(NULL, $_GET['val']);
 }
开发者ID:Lirriella,项目名称:example,代码行数:7,代码来源:BooksController.php


示例12: 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


示例13: actionSample

 public function actionSample()
 {
     $json = file_get_contents('E:\\xampp\\htdocs\\books\\protected\\data\\data.json');
     $arr = json_decode($json, true);
     foreach ($arr["Books"] as $item) {
         $model = new Books();
         $model->book_description = $item['Description'];
         $model->book_name = $item['Title'];
         $model->book_image = $item['Image'];
         $model->book_author = 'Anonymous';
         $model->book_publisher = 'It Ebook';
         $model->book_year = 2009;
         $model->created_at = time();
         $model->updated_at = time();
         $model->status = 1;
         $model->save(FALSE);
     }
 }
开发者ID:huynt57,项目名称:books,代码行数:18,代码来源:InsertController.php


示例14: 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


示例15: 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


示例16: index

 public function index($id = NULL)
 {
     if ($id == NULL) {
         $res = array('heading' => '404', 'message' => 'no such book');
         $this->load->view('errors/html/error_404', $res);
     } else {
         $this->load->model('Books');
         $book = Books::findByIds($id);
         // $comments = Comment::findOnCond();
         // TO DO
         $data = array('book' => $book);
         $this->load->view('book_details', $data);
     }
 }
开发者ID:unidentifiedme,项目名称:Toshokan,代码行数:14,代码来源:Book.php


示例17: getBookInfo

 public function getBookInfo($bookId)
 {
     if (empty($bookId)) {
         return array('result' => 'fail', 'message' => 'Не задан идентифкатор книги');
     }
     $bookInfo = Books::getBookInfo($bookId);
     if (count($bookInfo) <= 0) {
         return array('result' => 'success', 'message' => 'Книг с указанным идентификатором не найдено');
     }
     $info = array($bookInfo->getAttributes());
     $authors = array();
     foreach ($bookInfo->authors as $item) {
         $authors[] = $item->getAttributes();
     }
     $info['authors'] = $authors;
     return $info;
 }
开发者ID:norv95,项目名称:kmptest,代码行数:17,代码来源:SupplierA.php


示例18: setStatus

    public static function setStatus($id_user, $id_book, $status, $state)
    {
        global $current_user;
        $book = Books::getInstance()->getByIdLoaded($id_book);
        /* @var $book Book */
        if ($book->getQuality() >= BOOK::BOOK_QUALITY_BEST) {
            throw new Exception('book quality is best, you cant fix states');
        }
        if (!isset(self::$statuses[$status])) {
            throw new Exception('no status #' . $status);
        }
        if (!isset(self::$states[$state])) {
            throw new Exception('no status #' . $state);
        }
        $can_comment = false;
        if ($state > 0) {
            $query = 'SELECT `time` FROM `ocr` WHERE  `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . ' AND `state`=' . $state;
            $last_time = Database::sql2single($query);
            if (time() - $last_time > 24 * 60 * 60) {
                $can_comment = true;
            }
        }
        if ($state == 0 && $status !== 0) {
            // delete
            $query = 'DELETE FROM `ocr` WHERE  `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . '';
        } else {
            // upsert
            $query = 'INSERT INTO `ocr` SET `id_book`=' . $id_book . ', `id_user`=' . $id_user . ', `status`=' . $status . ',`state`=' . $state . ',`time`=' . time() . '
			ON DUPLICATE KEY UPDATE
			`time`=' . time() . ', `state`=' . $state;
        }
        if (!Database::query($query, false)) {
            throw new Exception('Duplicating #book ' . $id_book . ' #status' . $status . ' #state' . $state);
        }
        if ($state == 0) {
            $comment = 'User ' . $current_user->id . ' drop status ' . $status . ' state ' . $state . ' user_id ' . $id_user;
        } else {
            $comment = 'User ' . $current_user->id . ' set status ' . $status . ' state ' . $state . ' user_id ' . $id_user;
        }
        $comUser = Users::getById($id_user);
        /* @var $comUser User */
        if ($can_comment && ($part = self::getMessagePart($status, $state))) {
            $comment = mb_strtolower($part, 'UTF-8') . ' книгу';
            MongoDatabase::addSimpleComment(BiberLog::TargetType_book, $id_book, $id_user, $comment);
        }
    }
开发者ID:rasstroen,项目名称:metro,代码行数:46,代码来源:Ocr.php


示例19: 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


示例20: notifyGenreNewBook

 public static function notifyGenreNewBook($id_genre, $id_book)
 {
     global $current_user;
     $query = 'SELECT `id_user` FROM `genre_subscribers` WHERE `id_genre`=' . (int) $id_genre;
     $user_ids = array_keys(Database::sql2array($query, 'id_user'));
     if (isset($user_ids[$current_user->id])) {
         unset($user_ids[$current_user->id]);
     }
     if (count($user_ids)) {
         $genre = Database::sql2single('SELECT `title` FROM `genre` WHERE `id`=' . $id_genre);
         $book = Books::getInstance()->getByIdLoaded($id_book);
         /* @var $person Person */
         $subject = 'Добавлена книга в жанре ' . $genre;
         /* @var $book Book */
         $message = 'Книга <a href="/b/' . $book->id . '">' . $book->getTitle(1) . '</a> добавлена';
         self::send($user_ids, $subject, $message, UserNotify::UN_G_NEW_GENRES);
     }
 }
开发者ID:rasstroen,项目名称:metro,代码行数:18,代码来源:Notify.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP BookstoreDataPopulator类代码示例发布时间:2022-05-23
下一篇:
PHP Bookmark类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap