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


PHP Book::setAuthor方法代码示例

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


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

示例1: handlePUT

function handlePUT(mysqli $conn)
{
    parse_str(file_get_contents("php://input"), $data);
    $book = new Book();
    $book->update($conn, $data['id']);
    $book->setTitle($data['title']);
    $book->setAuthor($data['author']);
    $book->setDesc($data['desc']);
}
开发者ID:RyszardRzepa,项目名称:REST_API,代码行数:9,代码来源:Books.php

示例2: bookInsertion

 function bookInsertion($title, $ISBN, $author)
 {
     $book = new \Book();
     $book->setTitle($title);
     $book->setISBN($ISBN);
     $book->setAuthor($author);
     $book->save();
     return $book;
 }
开发者ID:Big-Shark,项目名称:php-orm-benchmark,代码行数:9,代码来源:TestDefault.php

示例3: runBookInsertion

 function runBookInsertion($i)
 {
     $book = new Book();
     $book->setTitle('Hello' . $i);
     $book->setAuthor($this->authors[array_rand($this->authors)]);
     $book->setISBN('1234');
     $book->setPrice($i);
     $book->save($this->con);
     $this->books[] = $book->getId();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:10,代码来源:Propel20TestSuite.php

示例4: handlePUT

function handlePUT()
{
    $conn = Connection::startConnection();
    parse_str(file_get_contents("php://input"), $data);
    header('Content-type: application/json');
    $book = new Book();
    $book->setName($data['name']);
    $book->setAuthor($data['author']);
    $book->setDesc($data['opis']);
    $book->updateBook($conn, $data['id']);
    Connection::stopConnecion($conn);
}
开发者ID:kfiatos,项目名称:Bookstore,代码行数:12,代码来源:books.php

示例5: testSerializeObjectWithRelations

 public function testSerializeObjectWithRelations()
 {
     $author = new Author();
     $author->setFirstName('John');
     $book = new Book();
     $book->setTitle('Foo4');
     $book->setISBN('1234');
     $book->setAuthor($author);
     $book->save();
     $b = clone $book;
     $sb = serialize($b);
     $book->clearAllReferences();
     $this->assertEquals($book, unserialize($sb));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:14,代码来源:BaseObjectSerializeTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     BookstoreDataPopulator::populate();
     $cr = new Criteria();
     $cr->add(AuthorPeer::LAST_NAME, "Rowling");
     $cr->add(AuthorPeer::FIRST_NAME, "J.K.");
     $rowling = AuthorPeer::doSelectOne($cr);
     $this->authorId = $rowling->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Philosopher's Stone");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Chamber of Secrets");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Prisoner of Azkaban");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Goblet of Fire");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Half-Blood Prince");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Deathly Hallows");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:46,代码来源:PropelPagerTest.php

示例7: runBookInsertion

 function runBookInsertion($i)
 {
     $rand = array_rand($this->authors);
     $book = new Book();
     $book->setTitle('Hello' . $i);
     $book->setAuthor($this->authors[$rand]);
     $book->setISBN('1234');
     $book->setPrice($i);
     $this->session->persist($book);
     $this->session->persist($this->authors[$rand]);
     $this->books[] = $book;
     $this->i++;
     if ($this->i >= 500) {
         $this->commit();
         $this->beginTransaction();
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:17,代码来源:PropelDMTestSuite.php

示例8: testCloneContainingObjects

 public function testCloneContainingObjects()
 {
     $a = new Author();
     $b = new Book();
     $b->setAuthor($a);
     $b->setISBN('ISBN1');
     $b1 = new Book();
     $b1->setPrice(5.55);
     $col = new PropelCollection(array($b, $b1));
     $clone = clone $col;
     $orgCount = $col->getIterator()->count();
     $cloneCount = $clone->getIterator()->count();
     $this->assertEquals($orgCount, $cloneCount, 'cloned collections have the same size');
     $this->assertEquals($b, $clone[0], 'cloned objects are equal');
     $this->assertEquals($b1, $clone[1], 'cloned objects are equal');
     $this->assertNotSame($b, $clone[0], 'cloned objects are copies, not identical');
     $this->assertNotSame($b1, $clone[1], 'cloned objects are copies, not identical');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:18,代码来源:PropelCollectionTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $publisher = new Publisher();
     $publisher->setId(1234);
     $publisher->setName('Penguin');
     $author = new Author();
     $author->setId(5678);
     $author->setFirstName('George');
     $author->setLastName('Byron');
     $book = new Book();
     $book->setId(9012);
     $book->setTitle('Don Juan');
     $book->setISBN('0140422161');
     $book->setPrice(12.99);
     $book->setAuthor($author);
     $book->setPublisher($publisher);
     $this->book = $book;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:19,代码来源:BaseObjectConvertTest.php

示例10: testUtf8

 public function testUtf8()
 {
     $db = Propel::getDB(BookPeer::DATABASE_NAME);
     $title = "Смерть на брудершафт. Младенец и черт";
     //        1234567890123456789012345678901234567
     //                 1         2         3
     $a = new Author();
     $a->setFirstName("Б.");
     $a->setLastName("АКУНИН");
     $p = new Publisher();
     $p->setName("Детектив российский, остросюжетная проза");
     $b = new Book();
     $b->setTitle($title);
     $b->setISBN("B-59246");
     $b->setAuthor($a);
     $b->setPublisher($p);
     $b->save();
     $b->reload();
     $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title.");
     $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:21,代码来源:CharacterEncodingTest.php

示例11: testSaveReturnValues

 /**
  * Test saving an object and getting correct number of affected rows from save().
  * This includes tests of cascading saves to fk-related objects.
  */
 public function testSaveReturnValues()
 {
     $author = new Author();
     $author->setFirstName("Mark");
     $author->setLastName("Kurlansky");
     // do not save
     $pub = new Publisher();
     $pub->setName("Penguin Books");
     // do not save
     $book = new Book();
     $book->setTitle("Salt: A World History");
     $book->setISBN("0142001619");
     $book->setAuthor($author);
     $book->setPublisher($pub);
     $affected = $book->save();
     $this->assertEquals(3, $affected, "Expected 3 affected rows when saving book + publisher + author.");
     // change nothing ...
     $affected = $book->save();
     $this->assertEquals(0, $affected, "Expected 0 affected rows when saving already-saved book.");
     // modify the book (UPDATE)
     $book->setTitle("Salt A World History");
     $affected = $book->save();
     $this->assertEquals(1, $affected, "Expected 1 affected row when saving modified book.");
     // modify the related author
     $author->setLastName("Kurlanski");
     $affected = $book->save();
     $this->assertEquals(1, $affected, "Expected 1 affected row when saving book with updated author.");
     // modify both the related author and the book
     $author->setLastName("Kurlansky");
     $book->setTitle("Salt: A World History");
     $affected = $book->save();
     $this->assertEquals(2, $affected, "Expected 2 affected rows when saving updated book with updated author.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:37,代码来源:GeneratedObjectTest.php

示例12: boolTest

    $failures2 = $bk1->getValidationFailures();
    print "Making sure 6 validation messages were returned: ";
    print boolTest(count($failures2) === 3);
    print "Making sure correct columns failed: ";
    print boolTest(array_keys($failures2) === array(AuthorPeer::LAST_NAME, BookPeer::TITLE, ReviewPeer::REVIEWED_BY));
    $bk2 = new Book();
    $bk2->setTitle("12345678901");
    // passes
    $auth2 = new Author();
    $auth2->setLastName("Blah");
    //passes
    $auth2->setEmail("some@body.com");
    //passes
    $auth2->setAge(50);
    //passes
    $bk2->setAuthor($auth2);
    $rev2 = new Review();
    $rev2->setReviewedBy("Me!");
    // passes
    $rev2->setStatus("new");
    // passes
    $bk2->addReview($rev2);
    $ret3 = $bk2->validate();
    print "Making sure complex validation can pass: ";
    print boolTest($ret3 === true);
} catch (Exception $e) {
    die("Error doing validation tests: " . $e->__toString());
}
// Test doCount()
//
try {
开发者ID:yasirgit,项目名称:afids,代码行数:31,代码来源:bookstore-test.php

示例13: testDoSelectJoin_NullFk

 /**
  * Test the doSelectJoin*() methods when the related object is NULL.
  */
 public function testDoSelectJoin_NullFk()
 {
     $b1 = new Book();
     $b1->setTitle("Test NULLFK 1");
     $b1->setISBN("NULLFK-1");
     $b1->save();
     $b2 = new Book();
     $b2->setTitle("Test NULLFK 2");
     $b2->setISBN("NULLFK-2");
     $b2->setAuthor(new Author());
     $b2->getAuthor()->setFirstName("Hans")->setLastName("L");
     $b2->save();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     $c = new Criteria();
     $c->add(BookPeer::ISBN, 'NULLFK-%', Criteria::LIKE);
     $c->addAscendingOrderByColumn(BookPeer::ISBN);
     $matches = BookPeer::doSelectJoinAuthor($c);
     $this->assertEquals(2, count($matches), "Expected 2 matches back from new books; got back " . count($matches));
     $this->assertNull($matches[0]->getAuthor(), "Expected first book author to be null");
     $this->assertInstanceOf('Author', $matches[1]->getAuthor(), "Expected valid Author object for second book.");
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:25,代码来源:GeneratedPeerDoSelectTest.php

示例14: testDoValidate_ComplexSpecifiedCols

 /**
  * Test recursive validaton with specified columns.
  */
 public function testDoValidate_ComplexSpecifiedCols()
 {
     $book = new Book();
     $book->setTitle("12345");
     // min length is 10
     $author = new Author();
     $author->setFirstName("Hans");
     // last name required, valid email format, age > 0
     $review = new Review();
     $review->setReviewDate("08/09/2001");
     // reviewed_by column required, invalid status (new, reviewed, archived)
     $book->setAuthor($author);
     $book->addReview($review);
     $cols = array(AuthorPeer::LAST_NAME, ReviewPeer::REVIEWED_BY);
     $res = $book->validate($cols);
     $this->assertFalse($res, "Expected validation to fail.");
     $failures = $book->getValidationFailures();
     /* Make sure 3 validation messages were returned; NOT 6, because the others were NULL */
     $this->assertEquals(2, count($failures), "");
     /* Make sure correct columns failed */
     $expectedCols = array(AuthorPeer::LAST_NAME, ReviewPeer::REVIEWED_BY);
     $returnedCols = array_keys($failures);
     /* implode for readability */
     $this->assertEquals(implode(',', $expectedCols), implode(',', $returnedCols));
 }
开发者ID:nhemsley,项目名称:propel,代码行数:28,代码来源:ValidatorTest.php

示例15: testToArrayDeep

 public function testToArrayDeep()
 {
     $author = new Author();
     $author->setId(5678);
     $author->setFirstName('George');
     $author->setLastName('Byron');
     $book = new Book();
     $book->setId(9012);
     $book->setTitle('Don Juan');
     $book->setISBN('0140422161');
     $book->setPrice(12.99);
     $book->setAuthor($author);
     $coll = new PropelArrayCollection();
     $coll->setModel('Book');
     $coll[] = $book->toArray(BasePeer::TYPE_PHPNAME, true, array(), true);
     $expected = array(array('Id' => 9012, 'Title' => 'Don Juan', 'ISBN' => '0140422161', 'Price' => 12.99, 'PublisherId' => null, 'AuthorId' => 5678, 'Author' => array('Id' => 5678, 'FirstName' => 'George', 'LastName' => 'Byron', 'Email' => null, 'Age' => null, 'Books' => array('Book_0' => '*RECURSION*'))));
     $this->assertEquals($expected, $coll->toArray());
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:18,代码来源:PropelArrayCollectionTest.php


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