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


PHP Books::save方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:Araused,项目名称:books,代码行数:13,代码来源:BooksController.php

示例2: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
开发者ID:ZlatanNikolich,项目名称:yiisrk,代码行数:14,代码来源:BooksController.php

示例3: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'authors' => $this->getAuthorsArray(Authors::find()->all())]);
     }
 }
开发者ID:alaz1987,项目名称:books,代码行数:14,代码来源:BooksController.php

示例4: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     $model->date_create = $model->date_update = date('Y-m-d H:i:s');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(isset($_POST['referer']) ? $_POST['referer'] : '/');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:Pontorez,项目名称:kgr,代码行数:15,代码来源:BooksController.php

示例5: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $book = new Books();
     $author = new Authors();
     if ($book->load(Yii::$app->request->post()) && $book->save()) {
         return $this->redirect(['view', 'id' => $book->id]);
     } else {
         return $this->render('create', ['model' => $book, 'author' => $author]);
     }
 }
开发者ID:sergioIt,项目名称:basicdev,代码行数:15,代码来源:BooksController.php

示例6: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($closeOnLoad = false)
 {
     $model = new Books();
     $data = $this->filterData(Yii::$app->request->post());
     if ($model->load($data) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id, 'closeOnLoad' => $closeOnLoad]);
     } else {
         return $this->render('create', ['model' => $model, 'authors' => $this->getAuthorsForDropDownList()]);
     }
 }
开发者ID:alhimik1986,项目名称:test_for_job,代码行数:15,代码来源:BooksController.php

示例7: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $model->uploadImage();
         return $model->save() ? $this->redirect(['index']) : var_dump($model);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:akomyagin,项目名称:books,代码行数:15,代码来源:BooksController.php

示例8: actionCreate

 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $model->uploadImage();
         $model->date_create = date('Y-m-d');
         $model->date_update = date('Y-m-d');
         $model->save();
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:verve000,项目名称:verve000,代码行数:13,代码来源:BooksController.php

示例9: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     $model_b_a_rel = new BookAuthorRel();
     $authorsArr = Authors::authorArr();
     if ($model->load(Yii::$app->request->post()) && $model_b_a_rel->load(Yii::$app->request->post())) {
         $model->save();
         $model_b_a_rel->b_id = $model->id;
         $model_b_a_rel->saveMultiple();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'model_b_a_rel' => $model_b_a_rel, 'authorsArr' => $authorsArr]);
     }
 }
开发者ID:snedi,项目名称:book-management,代码行数:19,代码来源:BooksController.php

示例10: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post()) && $model->upload()) {
         //var_dump(Yii::$app->request->post());die();
         if ($model->save()) {
             return $this->redirect(['index']);
         } else {
             return $this->render('create', ['authors' => Authors::find()->all(), 'model' => $model]);
         }
     } else {
         return $this->render('create', ['authors' => Authors::find()->all(), 'model' => $model]);
     }
 }
开发者ID:logs12,项目名称:books,代码行数:19,代码来源:BooksController.php

示例11: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     $modelAuthorsBooks = new AuthorsBooks();
     $data = Yii::$app->request->post();
     if ($model->load($data) && $model->save()) {
         $modelAuthorsBooks->a_id = $data['AuthorsBooks']['a_id'][0];
         $modelAuthorsBooks->b_id = $model->id;
         if ($modelAuthorsBooks->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'modelAuthorsBooks' => $modelAuthorsBooks]);
     }
 }
开发者ID:snedi,项目名称:imot,代码行数:20,代码来源:BooksController.php

示例12: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $upload_file = $model->uploadFile();
         var_dump($model->validate());
         if ($model->validate()) {
             if ($model->save()) {
                 if ($upload_file !== false) {
                     $path = $model->getUploadedFile();
                     $upload_file->saveAs($path);
                 }
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:fedman,项目名称:books,代码行数:23,代码来源:BooksController.php

示例13: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $image = $model->uploadImage();
         if ($image !== false) {
             $path = $model->getImageFile();
             $image->saveAs($path);
         }
         //                if ($path = $model->upload()) {
         //                    $model->preview_image = $path;
         //                }
         $model->save();
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'authors' => Authors::getAuthorsList()]);
     }
 }
开发者ID:Cranky4,项目名称:books_test,代码行数:23,代码来源:BooksController.php

示例14: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     $id = $request->get('id');
     $book = Books::find($id);
     $result = Validator::make(Input::all(), ['title' => 'required', 'author' => 'required', 'publisher' => 'required', 'isbn' => "required|max:13|min:13|regex:/^[1-9][0-9]{12}\$/"], ['title.required' => 'Book title is required', 'author.required' => 'Book author is required', 'isbn.required' => 'ISBN is required', 'isbn.max' => 'ISBN must be exactly 13 characters', 'isbn.min' => 'ISBN must be exactly 13 characters', 'isbn.regex' => 'ISBN must contain numbers only.', 'publisher.required' => 'Publisher is required']);
     if ($result->fails()) {
         $result->errors()->add('submitted', 1);
         $result->errors()->add('desc', Input::get('description') !== "" ? TRUE : FALSE);
         return redirect()->route('books.new')->withErrors($result->errors())->withInput();
     }
     $book->title = $request->get("title");
     $book->author_id = $request->get("author_id");
     $book->isbn = $request->get("isbn");
     $book->description = $request->get('description');
     $book->date_published = $request->get('date_published');
     $affected = $book->save();
     if ($affected > 0) {
         $book = new Books();
         $book->title = $request->get("title");
         $book->author_id = $request->get('author_id');
         $book->publisher_id = $request->get('publisher_id');
         $book->isbn = $request->get("isbn");
         $book->description = $request->get('description');
         $book->date_published = $request->get('date_published');
         $book->record_id = $id;
         $book->save();
     }
     return redirect()->route('books.home')->with('status', "Update successful")->withInput();
 }
开发者ID:jmnerd07,项目名称:book-management,代码行数:36,代码来源:BooksController.php

示例15: actionCreate

 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $authors_model = Authors::find()->all();
     $authors = [];
     foreach ($authors_model as $author) {
         $authors[$author->author_id] = $author->firstname . " " . $author->lastname;
     }
     $model = new Books();
     $post = Yii::$app->request->post();
     if (isset(Yii::$app->request->post()["Books"])) {
         $post["Books"]["date_create"] = date("Y-m-d");
         $post["Books"]["date_update"] = date("Y-m-d");
     }
     if ($model->load($post) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'authors' => $authors]);
     }
 }
开发者ID:Kakiho,项目名称:testtask,代码行数:24,代码来源:BooksController.php


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