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


PHP Books::save方法代码示例

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


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

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // check if method is post
     if (Request::isMethod('post')) {
         $input = Input::all();
         $validator = Validator::make($input, array('title' => 'required', 'author' => 'required', 'genre' => 'required'));
         // check if data is validated
         if ($validator->fails()) {
             // redirect with errors if the given data did not pass validation
             return Redirect::to('create')->withErrors($validator);
         }
         $book = new Books();
         $book->title = Input::get('title');
         $book->author = Input::get('author');
         $book->genre = Input::get('genre');
         $book->description = Input::get('description');
         $book->published = Input::get('published');
         $book->format = Input::get('format');
         // check if an image is added.
         if (Input::hasFile('image')) {
             $destinationPath = public_path() . '/uploads/';
             $original_filename = Input::file('image')->getClientOriginalName();
             $extension = Input::file('image')->getClientOriginalExtension();
             $filename = md5(uniqid() . $original_filename);
             // save file
             Input::file('image')->move($destinationPath, $filename . '.' . $extension);
             $book->image = $filename . '.' . $extension;
         }
         $book->save();
         return Redirect::to('/')->with('success', Lang::get('labels.bookadded'));
     }
 }
开发者ID:peterporras,项目名称:bookstore,代码行数:37,代码来源:BooksController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('title' => 'required', 'author' => 'required', 'year' => 'required', 'isbn' => 'required', 'price' => 'required', 'stock' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('books/create');
     } else {
         // imagen
         $filename = Input::get('isbn') . '.jpg';
         $path = public_path() != '' ? public_path() : '/public/cover';
         $destinationPath = $path;
         if (Input::file('cover') != "") {
             Input::file('cover')->move($destinationPath, $filename);
         }
         var_dump($path);
         // store
         $books = new Books();
         $books->title = Input::get('title');
         $books->cover = $filename;
         $books->author = Input::get('author');
         $books->year = Input::get('year');
         $books->isbn = Input::get('isbn');
         $books->price = Input::get('price');
         $books->stock = Input::get('stock');
         $books->save();
         // redirect
         Session::flash('message', $destinationPath);
         return Redirect::to('books/create');
     }
 }
开发者ID:BrUn3y,项目名称:dracarys,代码行数:38,代码来源:BooksController.php

示例5: actionCreate

 public function actionCreate()
 {
     $book = new Books();
     if (isset($_REQUEST['Books'])) {
         $book->setAttributes($_REQUEST['Books']);
     }
     if (isset($_REQUEST['save']) && $_REQUEST['save']) {
         $book->save();
     }
     $this->render('create', array('book' => $book));
 }
开发者ID:Lirriella,项目名称:example,代码行数:11,代码来源:BooksController.php

示例6: store

 public function store()
 {
     $validator = Validator::make(Input::all(), Books::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     } else {
         $books = new Books();
         $books->bname = Input::get('bname');
         $books->bauthor = Input::get('bauthor');
         $books->bedition = Input::get('bedition');
         $books->phone = Input::file('image');
         $books->save();
         return Redirect::route('books.index');
     }
 }
开发者ID:pnagaraju25,项目名称:larvelCrudFinal,代码行数:15,代码来源:BookController.php

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

示例8: addBook

 public function addBook($book_name, $book_author, $book_year, $book_publisher, $book_image, $book_description)
 {
     $model = new Books();
     $model->book_name = $book_name;
     $model->book_author = $book_author;
     $model->book_year = $book_year;
     $model->book_publisher = $book_publisher;
     $model->book_image = $book_image;
     $model->created_at = time();
     $model->updated_at = time();
     $model->status = 1;
     $model->book_description = $book_description;
     if ($model->save(FALSE)) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:huynt57,项目名称:books,代码行数:18,代码来源:Books.php

示例9: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Books();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Books'])) {
         $model->attributes = $_POST['Books'];
         foreach ($model->attributes as $key => &$atr) {
             if (empty($atr)) {
                 $model->{$key} = null;
             }
         }
         if ($model->save()) {
             if (!empty($_FILES['Books']['name']['ext1']) && $model->delete_img1 == '0') {
                 $model->ext1 = CUploadedFile::getInstance($model, 'ext1');
                 if ($model->ext1) {
                     $ext1 = $model->ext1->extensionName;
                     $file = Yii::app()->basePath . '/../images/' . mb_strtolower('Books') . '/' . $model->id . "_1." . $ext1;
                     $model->ext1->saveAs($file);
                     $model->ext1 = $ext1;
                     $model->save();
                 }
             } else {
                 if ($model->delete_img1 == '1') {
                     $filename = Yii::app()->basePath . '/../images/' . mb_strtolower('Books') . '/' . $model->id . "." . $model->ext1;
                     if (file_exists($filename)) {
                         unlink($filename);
                     }
                     $model->ext1 = '';
                     $model->save();
                 }
             }
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:vetalded,项目名称:homelibrary16mbcom,代码行数:43,代码来源:BooksController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('title' => 'required', 'author' => 'required', 'year' => 'required', 'isbn' => 'required', 'price' => 'required', 'stock' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('books/create');
     } else {
         // store
         $books = new Books();
         $books->title = Input::get('title');
         $books->author = Input::get('author');
         $books->year = Input::get('year');
         $books->isbn = Input::get('isbn');
         $books->price = Input::get('price');
         $books->stock = Input::get('stock');
         $books->save();
         // redirect
         Session::flash('message', 'Guardado exitosamente en la base de datos!');
         return Redirect::to('books/create');
     }
 }
开发者ID:JoseJesusOchoaTorres,项目名称:dracarys,代码行数:29,代码来源:BooksController.php

示例11: unlink

                            unlink($_GET['image']);
                        } else {
                            $errors[] = "Imaginea nu a fost salvata";
                        }
                    }
                }
                if (!$errors) {
                    $book = new Books();
                    $book->name = $_POST['name'];
                    $book->category_id = $_POST['category'];
                    $book->author = $_POST['author'];
                    $book->price = $_POST['price'];
                    if (isset($target)) {
                        $book->image = $target;
                    }
                    if ($book->save($_GET['id']) == 1) {
                        $_SESSION['succes'] = "Cartea \"{$book->name}\" a fost editata!";
                        header("Location: books.php");
                    } else {
                        header("Location: books.php");
                    }
                }
            } catch (Exception $e) {
                $errors[] = $e->getMessage();
            }
        }
    }
    ?>
	<div class="panel panel-default">
        <div class="panel-heading"><?php 
    echo $title;
开发者ID:alexandrumanta,项目名称:Netop-test,代码行数:31,代码来源:books.php

示例12: import

 public static function import($jsonDatas, $keep_ids = FALSE, $logged = FALSE)
 {
     global $_CONFIG;
     if (!$logged) {
         die('You are not authorized to import books.');
     }
     $datas = json_decode($jsonDatas, TRUE);
     if (!isset($datas['books']) || !isset($datas['posters'])) {
         return FALSE;
     }
     $booksDatas = $datas['books'];
     $images = $datas['posters'];
     $id = time();
     $i = 0;
     $books = new Books($logged);
     foreach ($booksDatas as $book) {
         $id = $keep_ids && isset($book['id']) ? $book['id'] : $id;
         while (isset($books[$id])) {
             $id--;
         }
         $inputs = array('id' => $id, 'title' => isset($book['title']) ? trim(self::html_escaped($book['title'])) : NULL, 'author' => isset($book['author']) ? trim(self::html_escaped($book['author'])) : NULL, 'summary' => isset($book['summary']) ? checkNewLineContent(preg_replace('#<br( /)?>#', '', $book['summary'])) : NULL, 'publisher' => isset($book['publisher']) ? trim(self::html_escaped($book['publisher'])) : NULL, 'status' => isset($book['status']) && $book['status'] != NULL ? Book::SEEN : NULL, 'note' => isset($book['note']) ? checkRatingNote($book['note'], isset($book['status']) && $book['status'] != NULL ? Book::SEEN : NULL) : NULL, 'read_date' => isset($book['read_date']) ? checkInputDate($book['read_date']) : NULL, 'review' => isset($book['review']) ? checkNewLineContent(preg_replace('#<br( /)?>#', '', $book['review'])) : NULL, 'genre' => isset($book['genre']) ? checkGenre($book['genre']) : NULL, 'publication_year' => isset($book['release_date']) ? checkInputYear($book['release_date']) : NULL, 'pages' => isset($book['pages']) ? checkPages($book['pages']) : NULL, 'country' => isset($book['country']) ? checkCountry($book['country']) : NULL, 'link_website' => isset($book['link_website']) ? checkLink($book['link_website']) : NULL, 'link_image' => NULL);
         if (empty($inputs['title']) && empty($inputs['author']) && empty($inputs['summary'])) {
             continue;
         }
         if (function_exists('imagecreatefromjpeg') && !empty($images[$i])) {
             $image = explode(',', $images[$i]);
             if (!isset($image[1])) {
                 continue;
             }
             $imported = file_put_contents($_CONFIG['images'] . '/' . $id . '.jpg', base64_decode($image[1]));
             if ($imported == false) {
                 continue;
             }
             $inputs['link_image'] = $_CONFIG['images'] . '/' . $id . '.jpg';
         }
         $books[$id] = $inputs;
         $i++;
     }
     $books->save();
     return TRUE;
 }
开发者ID:Devenet,项目名称:MyBooks,代码行数:41,代码来源:index.php

示例13: actionAddNewBook

 public function actionAddNewBook()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $book_model = new Books();
         $book_attributes = $_POST['Books'];
         $book_attributes['creation_date'] = date('Y-m-d H:i:s');
         $book_model->attributes = $book_attributes;
         if ($book_model->validate()) {
             if ($book_model->save()) {
                 $last_insert_book_id = $book_model->id;
                 $relation_array = array();
                 foreach ($_POST['author_list'] as $author) {
                     $relation_array[] = array('book_id' => $last_insert_book_id, 'author_id' => $author);
                 }
                 $builder = Yii::app()->db->schema->commandBuilder;
                 $command = $builder->createMultipleInsertCommand('authors_books_relation', $relation_array);
                 $command->execute();
                 $transaction->commit();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Новая книга добавлена');
                 $this->redirect(array('library/tabs&tab_id=books'));
             }
         }
     } catch (CDbException $e) {
         $transaction->rollback();
     }
 }
开发者ID:maxim-bondarenko,项目名称:library,代码行数:27,代码来源:LibraryController.php


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