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


PHP Book::setAuthor方法代码示例

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


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

示例1: 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:norfil,项目名称:Propel2,代码行数:14,代码来源:BaseObjectSerializeTest.php

示例2: 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:RafalFilipek,项目名称:Propel2,代码行数:46,代码来源:PropelPagerTest.php

示例3: 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:disider,项目名称:Propel2,代码行数:19,代码来源:ActiveRecordConvertTest.php

示例4: testGroupByArray

 public function testGroupByArray()
 {
     $stephenson = new Author();
     $stephenson->setFirstName("Neal");
     $stephenson->setLastName("Stephenson");
     $stephenson->save();
     $byron = new Author();
     $byron->setFirstName("George");
     $byron->setLastName("Byron");
     $byron->save();
     $phoenix = new Book();
     $phoenix->setTitle("Harry Potter and the Order of the Phoenix");
     $phoenix->setISBN("043935806X");
     $phoenix->setAuthor($stephenson);
     $phoenix->save();
     $qs = new Book();
     $qs->setISBN("0380977427");
     $qs->setTitle("Quicksilver");
     $qs->setAuthor($stephenson);
     $qs->save();
     $dj = new Book();
     $dj->setISBN("0140422161");
     $dj->setTitle("Don Juan");
     $dj->setAuthor($stephenson);
     $dj->save();
     $td = new Book();
     $td->setISBN("067972575X");
     $td->setTitle("The Tin Drum");
     $td->setAuthor($byron);
     $td->save();
     $authors = AuthorQuery::create()->leftJoinBook()->select(array('FirstName', 'LastName'))->withColumn('COUNT(Book.Id)', 'nbBooks')->groupBy(array('FirstName', 'LastName'))->orderByLastName()->find();
     $expectedSql = 'SELECT COUNT(book.id) AS nbBooks, author.first_name AS "FirstName", author.last_name AS "LastName" FROM author LEFT JOIN book ON (author.id=book.author_id) GROUP BY author.first_name,author.last_name ORDER BY author.last_name ASC';
     $this->assertEquals($expectedSql, $this->con->getLastExecutedQuery());
     $this->assertEquals(2, count($authors));
     $this->assertEquals('George', $authors[0]['FirstName']);
     $this->assertEquals(1, $authors[0]['nbBooks']);
     $this->assertEquals('Neal', $authors[1]['FirstName']);
     $this->assertEquals(3, $authors[1]['nbBooks']);
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:39,代码来源:ModelCriteriaGroupByArrayTest.php

示例5: testUtf8

 public function testUtf8()
 {
     $this->markTestSkipped('Skipped because of weird behavior on some platforms');
     $db = Propel::getServiceContainer()->getAdapter(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:norfil,项目名称:Propel2,代码行数:22,代码来源:CharacterEncodingTest.php

示例6: 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 ArrayCollection();
     $coll->setModel('Propel\\Tests\\Bookstore\\Book');
     $coll[] = $book->toArray(TableMap::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:badelas,项目名称:thelia,代码行数:18,代码来源:ArrayCollectionTest.php

示例7: testScenarioUsingQuery

 public function testScenarioUsingQuery()
 {
     // Add publisher records
     // ---------------------
     try {
         $scholastic = new Publisher();
         $scholastic->setName("Scholastic");
         // do not save, will do later to test cascade
         $morrow = new Publisher();
         $morrow->setName("William Morrow");
         $morrow->save();
         $morrow_id = $morrow->getId();
         $penguin = new Publisher();
         $penguin->setName("Penguin");
         $penguin->save();
         $penguin_id = $penguin->getId();
         $vintage = new Publisher();
         $vintage->setName("Vintage");
         $vintage->save();
         $vintage_id = $vintage->getId();
         $this->assertTrue(true, 'Save Publisher records');
     } catch (Exception $e) {
         $this->fail('Save publisher records');
     }
     // Add author records
     // ------------------
     try {
         $rowling = new Author();
         $rowling->setFirstName("J.K.");
         $rowling->setLastName("Rowling");
         // do not save, will do later to test cascade
         $stephenson = new Author();
         $stephenson->setFirstName("Neal");
         $stephenson->setLastName("Stephenson");
         $stephenson->save();
         $stephenson_id = $stephenson->getId();
         $byron = new Author();
         $byron->setFirstName("George");
         $byron->setLastName("Byron");
         $byron->save();
         $byron_id = $byron->getId();
         $grass = new Author();
         $grass->setFirstName("Gunter");
         $grass->setLastName("Grass");
         $grass->save();
         $grass_id = $grass->getId();
         $this->assertTrue(true, 'Save Author records');
     } catch (Exception $e) {
         $this->fail('Save Author records');
     }
     // Add book records
     // ----------------
     try {
         $phoenix = new Book();
         $phoenix->setTitle("Harry Potter and the Order of the Phoenix");
         $phoenix->setISBN("043935806X");
         $phoenix->setAuthor($rowling);
         $phoenix->setPublisher($scholastic);
         $phoenix->save();
         $phoenix_id = $phoenix->getId();
         $this->assertFalse($rowling->isNew(), 'saving book also saves related author');
         $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher');
         $qs = new Book();
         $qs->setISBN("0380977427");
         $qs->setTitle("Quicksilver");
         $qs->setAuthor($stephenson);
         $qs->setPublisher($morrow);
         $qs->save();
         $qs_id = $qs->getId();
         $dj = new Book();
         $dj->setISBN("0140422161");
         $dj->setTitle("Don Juan");
         $dj->setAuthor($byron);
         $dj->setPublisher($penguin);
         $dj->save();
         $dj_id = $qs->getId();
         $td = new Book();
         $td->setISBN("067972575X");
         $td->setTitle("The Tin Drum");
         $td->setAuthor($grass);
         $td->setPublisher($vintage);
         $td->save();
         $td_id = $td->getId();
         $this->assertTrue(true, 'Save Book records');
     } catch (Exception $e) {
         $this->fail('Save Author records');
     }
     // Add review records
     // ------------------
     try {
         $r1 = new Review();
         $r1->setBook($phoenix);
         $r1->setReviewedBy("Washington Post");
         $r1->setRecommended(true);
         $r1->setReviewDate(time());
         $r1->save();
         $r1_id = $r1->getId();
         $r2 = new Review();
         $r2->setBook($phoenix);
         $r2->setReviewedBy("New York Times");
//.........这里部分代码省略.........
开发者ID:norfil,项目名称:Propel2,代码行数:101,代码来源:BookstoreTest.php

示例8: testFindOneWithOneToManyCustomOrder

 public function testFindOneWithOneToManyCustomOrder()
 {
     $author1 = new Author();
     $author1->setFirstName('AA');
     $author2 = new Author();
     $author2->setFirstName('BB');
     $book1 = new Book();
     $book1->setTitle('Aaa');
     $book1->setAuthor($author1);
     $book1->save();
     $book2 = new Book();
     $book2->setTitle('Bbb');
     $book2->setAuthor($author2);
     $book2->save();
     $book3 = new Book();
     $book3->setTitle('Ccc');
     $book3->setAuthor($author1);
     $book3->save();
     $authors = AuthorQuery::create()->setFormatter(ModelCriteria::FORMAT_ARRAY)->leftJoin('Propel\\Tests\\Bookstore\\Author.Book')->orderBy('Book.Title')->with('Book')->find();
     $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count');
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:21,代码来源:ArrayFormatterWithTest.php

示例9: testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins

 public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins()
 {
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     BookOpinionTableMap::clearInstancePool();
     BookReaderTableMap::clearInstancePool();
     $freud = new Author();
     $freud->setFirstName("Sigmund");
     $freud->setLastName("Freud");
     $freud->save($this->con);
     $publisher = new Publisher();
     $publisher->setName('Psycho Books');
     $publisher->save();
     $book = new Book();
     $book->setAuthor($freud);
     $book->setTitle('Weirdness');
     $book->setIsbn('abc123456');
     $book->setPrice('14.99');
     $book->setPublisher($publisher);
     $book->save();
     $query = BookQuery::create()->filterByTitle('Weirdness')->innerJoinAuthor()->useBookOpinionQuery(null, Criteria::LEFT_JOIN)->leftJoinBookReader()->endUse()->with('Author')->with('BookOpinion')->with('BookReader');
     $books = $query->find($this->con)->get(0);
     $this->assertEquals(0, count($books->getBookOpinions()));
 }
开发者ID:disider,项目名称:Propel2,代码行数:24,代码来源:ObjectFormatterWithTest.php

示例10: 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:robin850,项目名称:Propel2,代码行数:37,代码来源:GeneratedObjectTest.php

示例11: 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:norfil,项目名称:Propel2,代码行数:28,代码来源:ValidatorTest.php

示例12: populate

 public static function populate($con = null)
 {
     if ($con === null) {
         $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     // Add publisher records
     // ---------------------
     $scholastic = new Publisher();
     $scholastic->setName("Scholastic");
     // do not save, will do later to test cascade
     $morrow = new Publisher();
     $morrow->setName("William Morrow");
     $morrow->save($con);
     $morrow_id = $morrow->getId();
     $penguin = new Publisher();
     $penguin->setName("Penguin");
     $penguin->save();
     $penguin_id = $penguin->getId();
     $vintage = new Publisher();
     $vintage->setName("Vintage");
     $vintage->save($con);
     $vintage_id = $vintage->getId();
     $rowling = new Author();
     $rowling->setFirstName("J.K.");
     $rowling->setLastName("Rowling");
     // no save()
     $stephenson = new Author();
     $stephenson->setFirstName("Neal");
     $stephenson->setLastName("Stephenson");
     $stephenson->save($con);
     $stephenson_id = $stephenson->getId();
     $byron = new Author();
     $byron->setFirstName("George");
     $byron->setLastName("Byron");
     $byron->save($con);
     $byron_id = $byron->getId();
     $grass = new Author();
     $grass->setFirstName("Gunter");
     $grass->setLastName("Grass");
     $grass->save($con);
     $grass_id = $grass->getId();
     $phoenix = new Book();
     $phoenix->setTitle("Harry Potter and the Order of the Phoenix");
     $phoenix->setISBN("043935806X");
     $phoenix->setAuthor($rowling);
     $phoenix->setPublisher($scholastic);
     $phoenix->setPrice(10.99);
     $phoenix->save($con);
     $phoenix_id = $phoenix->getId();
     $qs = new Book();
     $qs->setISBN("0380977427");
     $qs->setTitle("Quicksilver");
     $qs->setPrice(11.99);
     $qs->setAuthor($stephenson);
     $qs->setPublisher($morrow);
     $qs->save($con);
     $qs_id = $qs->getId();
     $dj = new Book();
     $dj->setISBN("0140422161");
     $dj->setTitle("Don Juan");
     $dj->setPrice(12.99);
     $dj->setAuthor($byron);
     $dj->setPublisher($penguin);
     $dj->save($con);
     $dj_id = $dj->getId();
     $td = new Book();
     $td->setISBN("067972575X");
     $td->setTitle("The Tin Drum");
     $td->setPrice(13.99);
     $td->setAuthor($grass);
     $td->setPublisher($vintage);
     $td->save($con);
     $td_id = $td->getId();
     $r1 = new Review();
     $r1->setBook($phoenix);
     $r1->setReviewedBy("Washington Post");
     $r1->setRecommended(true);
     $r1->setReviewDate(time());
     $r1->save($con);
     $r1_id = $r1->getId();
     $r2 = new Review();
     $r2->setBook($phoenix);
     $r2->setReviewedBy("New York Times");
     $r2->setRecommended(false);
     $r2->setReviewDate(time());
     $r2->save($con);
     $r2_id = $r2->getId();
     $blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif';
     $clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt';
     $m1 = new Media();
     $m1->setBook($td);
     $m1->setCoverImage(file_get_contents($blob_path));
     // CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943
     if (get_class(Propel::getServiceContainer()->getAdapter()) != "OracleAdapter") {
         $m1->setExcerpt(file_get_contents($clob_path));
     }
     $m1->save($con);
     // Add book list records
     // ---------------------
//.........这里部分代码省略.........
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:101,代码来源:BookstoreDataPopulator.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('Propel\\Tests\\Bookstore\\Author', $matches[1]->getAuthor(), "Expected valid Author object for second book.");
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:25,代码来源:GeneratedPeerDoSelectTest.php


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