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


PHP Author::save方法代码示例

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


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

示例1: testInvalidCharset

 public function testInvalidCharset()
 {
     $this->markTestSkipped();
     $db = Propel::getDB(BookPeer::DATABASE_NAME);
     if ($db instanceof DBSQLite) {
         $this->markTestSkipped();
     }
     $a = new Author();
     $a->setFirstName("Б.");
     $a->setLastName("АКУНИН");
     $a->save();
     $authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName());
     $a->setLastName($authorNameWindows1251);
     // Different databases seem to handle invalid data differently (no surprise, I guess...)
     if ($db instanceof DBPostgres) {
         try {
             $a->save();
             $this->fail("Expected an exception when saving non-UTF8 data to database.");
         } catch (Exception $x) {
             print $x;
         }
     } else {
         // No exception is thrown by MySQL ... (others need to be tested still)
         $a->save();
         $a->reload();
         $this->assertEquals("", $a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)");
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:28,代码来源:CharacterEncodingTest.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Book();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Book'])) {
         $authordetails = Author::model()->findByAttributes(array('author_name' => $_POST['Book']['author']));
         $publication = Publication::model()->findByAttributes(array('name' => $_POST['Book']['publisher']));
         $model->attributes = $_POST['Book'];
         if ($publication == NULL) {
             $publisher = new Publication();
             $publisher->name = $_POST['Book']['publisher'];
             $publisher->save();
             $model->publisher = $publisher->publication_id;
         } else {
             $model->publisher = $publication->publication_id;
         }
         if ($model->save()) {
             //echo count($authordetails).$authordetails->auth_id; exit;
             if ($authordetails) {
                 $model->author = $authordetails->auth_id;
                 $model->save();
             } else {
                 $author = new Author();
                 $author->author_name = $_POST['Book']['author'];
                 $author->save();
                 $model->author = $author->auth_id;
                 $model->save();
             }
             $model->status = 'C';
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:39,代码来源:BookController.php

示例3: makeAuthor

 /**
  * Helper to create "Author" model for tests.
  *
  * @param $name
  * @return Author
  */
 protected function makeAuthor($name)
 {
     $author = new Author();
     $author->name = $name;
     $author->save();
     return $author;
 }
开发者ID:ChrisReid,项目名称:eloquent-sluggable,代码行数:13,代码来源:SluggableTest.php

示例4: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAuthor !== null) {
             if ($this->aAuthor->isModified() || $this->aAuthor->isNew()) {
                 $affectedRows += $this->aAuthor->save($con);
             }
             $this->setAuthor($this->aAuthor);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:41,代码来源:BaseBook.php

示例5: postAdd

 public function postAdd()
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Add An Author - ' . $this->site_name;
     $input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug');
     $messages = ['unique' => 'The author already exists in the database.', 'url' => 'The :attribute field is not a valid URL.'];
     $validator = Validator::make($input, ['name' => 'required|unique:authors,name', 'website' => 'url', 'donate_link' => 'url'], $messages);
     if ($validator->fails()) {
         return Redirect::action('AuthorController@getAdd')->withErrors($validator)->withInput();
     }
     $author = new Author();
     $author->name = $input['name'];
     $author->deck = $input['deck'];
     $author->website = $input['website'];
     $author->donate_link = $input['donate_link'];
     $author->bio = $input['bio'];
     if ($input['slug'] == '') {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $author->slug = $slug;
     $author->last_ip = Request::getClientIp();
     $success = $author->save();
     if ($success) {
         return View::make('authors.add', ['title' => $title, 'success' => true]);
     }
     return Redirect::action('AuthorController@getAdd')->withErrors(['message' => 'Unable to add author.'])->withInput();
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:31,代码来源:AuthorController.php

示例6: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->setFirstName('John' . $i);
     $author->setLastName('Doe' . $i);
     $author->save($this->con);
     $this->authors[] = $author->getId();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:Propel17TestSuite.php

示例7: testDelete

 /** <tt>save && delete test</tt> */
 public function testDelete()
 {
     $item = new Author();
     $item->name = 'Andrei Cristescu';
     $item->save();
     $this->assertEqual($item->delete(), 1);
     $this->assertEqual($item->delete(), 0);
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:9,代码来源:DBOperationsTest.php

示例8: authorInsertion

 function authorInsertion($firstName, $lastName)
 {
     $author = new \Author();
     $author->first_name = $firstName;
     $author->last_name = $lastName;
     $author->save();
     return $author;
 }
开发者ID:Big-Shark,项目名称:php-orm-benchmark,代码行数:8,代码来源:TestDefault.php

示例9: lol

 public function lol()
 {
     $author = new Author();
     $author->setFirstName('Jane' . rand(1, 100));
     $author->setLastName('Austen' . rand(1, 100));
     $author->save();
     return $author;
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:8,代码来源:Test.php

示例10: post

 /**
  * Post name and email
  *
  * @param string $_name
  * @param string $_email
  *
  * return array {@type Author}
  *
  */
 public function post($_name, $_email)
 {
     $auth = new Author();
     $auth->name = $_name;
     $auth->email = $_email;
     $auth->save();
     return $auth;
 }
开发者ID:Alim-ifresco,项目名称:project1.dev4.why.sr,代码行数:17,代码来源:Authors.php

示例11: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->first_name = 'John' . $i;
     $author->last_name = 'Doe' . $i;
     $author->save($this->con);
     $this->authors[] = $author->id;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:Doctrine12TestSuite.php

示例12: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->firstName = 'John' . $i;
     $author->lastName = 'Doe' . $i;
     $author->save(false);
     $this->authors[] = $author;
 }
开发者ID:motin,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:YiiMTestSuite.php

示例13: prepareData

 /**
  * prepareData
  */
 public function prepareData()
 {
     for ($i = 0; $i < 10; $i++) {
         $oAuthor = new Author();
         $oAuthor->book_id = $i;
         $oAuthor->name = "Author {$i}";
         $oAuthor->save();
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:12,代码来源:574TestCase.php

示例14: checkAuthor

 function checkAuthor($author_name)
 {
     $new_author = null;
     if (Author::findByName($author_name)) {
         $new_author = Author::findByName($author_name);
     } else {
         $new_author = new Author($author_name);
         $new_author->save();
     }
     return $new_author;
 }
开发者ID:bdspen,项目名称:library_day1,代码行数:11,代码来源:Book.php

示例15: registerAction

 public function registerAction()
 {
     if ($this->request->isPost()) {
         $author = new Author();
         $data = $this->request->getPost('data');
         if (is_array($data) && count($data) > 0) {
             $data['password'] = password_hash($data['password'], PASSWORD_BCRYPT);
             $author->save($data);
             return $this->response->redirect('index/login');
         }
     }
 }
开发者ID:Akhundzade,项目名称:blog.today,代码行数:12,代码来源:IndexController.php


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