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


PHP Book::setIsbn方法代码示例

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


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

示例1: testFormatALotOfResults

 public function testFormatALotOfResults()
 {
     $nbBooks = 50;
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     Propel::disableInstancePooling();
     $book = new Book();
     for ($i = 0; $i < $nbBooks; $i++) {
         $book->clear();
         $book->setTitle('BookTest' . $i);
         $book->setIsbn('124' . $i);
         $book->save($con);
     }
     $stmt = $con->query('SELECT * FROM book');
     $formatter = new PropelOnDemandFormatter();
     $formatter->init(new ModelCriteria('bookstore', 'Book'));
     $books = $formatter->format($stmt);
     $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection');
     $this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query');
     $i = 0;
     foreach ($books as $book) {
         $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects');
         $this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query');
         $i++;
     }
     Propel::enableInstancePooling();
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:PropelOnDemandFormatterTest.php

示例2: createBooks

 protected function createBooks($nb = 15, $con = null)
 {
     BookQuery::create()->deleteAll($con);
     $books = new PropelObjectCollection();
     $books->setModel('Book');
     for ($i = 0; $i < $nb; $i++) {
         $b = new Book();
         $b->setTitle('Book' . $i);
         $b->setIsbn('12345' . $i);
         $books[] = $b;
     }
     $books->save($con);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:13,代码来源:PropelModelPagerTest.php

示例3: testHooksCall

 public function testHooksCall()
 {
     AuthorQuery::create()->deleteAll();
     BookQuery::create()->deleteAll();
     $author = new CountableAuthor();
     $author->setFirstName('Foo');
     $author->setLastName('Bar');
     $book = new Book();
     $book->setTitle('A title');
     $book->setIsbn('13456');
     $author->addBook($book);
     $author->save();
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(1, $author->nbCallPreSave);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:GeneratedObjectTest.php

示例4: testFindOneWithEmptyLeftJoin

 public function testFindOneWithEmptyLeftJoin()
 {
     // save a book with no author
     $b = new Book();
     $b->setTitle('Foo');
     $b->setIsbn('124');
     $b->save();
     $c = new ModelCriteria('bookstore', 'Book');
     $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
     $c->where('Book.Title = ?', 'Foo');
     $c->leftJoin('Book.Author');
     $c->with('Author');
     $c->limit(1);
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $books = $c->find($con);
     foreach ($books as $book) {
         break;
     }
     $count = $con->getQueryCount();
     $author = $book->getAuthor();
     $this->assertNull($author, 'Related object is not hydrated if empty');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:22,代码来源:PropelOnDemandFormatterWithTest.php

示例5: testSetterOneToMany

 public function testSetterOneToMany()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $coll = new PropelObjectCollection();
     $coll->setModel('Book');
     for ($i = 0; $i < 3; $i++) {
         $coll[] = new Book();
     }
     $this->assertEquals(3, $coll->count());
     $a = new Author();
     $a->setBooks($coll);
     $a->save();
     $this->assertInstanceOf('PropelObjectCollection', $a->getBooks());
     $this->assertEquals(3, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(3, BookQuery::create()->count());
     $coll->shift();
     $this->assertEquals(2, $coll->count());
     $a->setBooks($coll);
     $a->save();
     $this->assertEquals(2, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(2, BookQuery::create()->count());
     $newBook = new Book();
     $newBook->setTitle('My New Book');
     $newBook->setIsbn(1234);
     // Kind of new collection
     $coll = clone $coll;
     $coll[] = $newBook;
     $a->setBooks($coll);
     $a->save();
     $this->assertEquals(3, $coll->count());
     $this->assertEquals(3, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(3, BookQuery::create()->count());
     // Add a new object
     $newBook1 = new Book();
     $newBook1->setTitle('My New Book1');
     $newBook1->setIsbn(1256);
     // Existing collection - The fix around reference is tested here.
     $coll[] = $newBook1;
     $a->setBooks($coll);
     $a->save();
     $this->assertEquals(4, $coll->count());
     $this->assertEquals(4, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(4, BookQuery::create()->count());
     // Add the same collection
     $books = $a->getBooks();
     $a->setBooks($books);
     $a->save();
     $this->assertEquals(4, $books->count());
     $this->assertEquals(4, $a->getBooks()->count());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(4, BookQuery::create()->count());
 }
开发者ID:ratibus,项目名称:Crew,代码行数:58,代码来源:GeneratedObjectTest.php

示例6: testSetterCollection

 public function testSetterCollection()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     $books = new PropelObjectCollection();
     for ($i = 0; $i < 10; $i++) {
         $b = new Book();
         $b->setTitle('My Book ' . $i);
         $b->setIsbn($i);
         $books[] = $b;
     }
     $this->assertEquals(10, $books->count());
     // Basic usage
     $bookClubList1 = new BookClubList();
     $bookClubList1->setGroupLeader('BookClubList1 Leader');
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(10, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(10, BookQuery::create()->count());
     $this->assertEquals(10, BookListRelQuery::create()->count());
     $i = 0;
     foreach ($bookClubList1->getBooks() as $book) {
         $this->assertEquals('My Book ' . $i, $book->getTitle());
         $this->assertEquals($i++, $book->getIsbn());
     }
     // Remove an element
     $books->shift();
     $this->assertEquals(9, $books->count());
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(9, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(9, BookListRelQuery::create()->count());
     $this->assertEquals(10, BookQuery::create()->count());
     // Add a new object
     $newBook = new Book();
     $newBook->setTitle('My New Book');
     $newBook->setIsbn(1234);
     // Kind of new collection
     $books = clone $books;
     $books[] = $newBook;
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(10, $books->count());
     $this->assertEquals(10, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(10, BookListRelQuery::create()->count());
     $this->assertEquals(11, BookQuery::create()->count());
     // Add a new object
     $newBook1 = new Book();
     $newBook1->setTitle('My New Book1');
     $newBook1->setIsbn(1256);
     // Existing collection - The fix around reference is tested here.
     // Ths `$books` collection has ever been setted to the `$bookClubList1` object.
     // Here we are adding a new object into the collection but, in this process, it
     // added the new object in the internal `collBooks` of the `$bookClubList1`
     // object too.
     // That's why the new object is not tracked and the cross object is not created,
     // in `addBook()` we consider the `collBooks` ever contains this new object. It's
     // not true but this is the "reference" process.
     // By saying "all new objects have to be added", we solve this issue. To know if
     // it's the best solution is the question.
     $books[] = $newBook1;
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(11, $books->count());
     $this->assertEquals(11, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(11, BookListRelQuery::create()->count());
     $this->assertEquals(12, BookQuery::create()->count());
     // Add the same collection
     $books = $bookClubList1->getBooks();
     $bookClubList1->setBooks($books);
     $bookClubList1->save();
     $this->assertEquals(11, $books->count());
     $this->assertEquals(11, $bookClubList1->getBooks()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(11, BookListRelQuery::create()->count());
     $this->assertEquals(12, BookQuery::create()->count());
 }
开发者ID:natecj,项目名称:Propel,代码行数:83,代码来源:GeneratedObjectRelTest.php

示例7: testAddAfterRemoveKeepsReferences

 public function testAddAfterRemoveKeepsReferences()
 {
     $list = new BookClubList();
     $list->setGroupLeader('Archimedes Q. Porter');
     $book = new Book();
     $book->setTitle("Jungle Expedition Handbook");
     $book->setIsbn('TEST');
     $xref = new BookListRel();
     $xref->setBook($book);
     $xref->setBookClubList($list);
     $xref->save();
     $book->removeBookListRel($xref);
     $book->addBookListRel($xref);
     $book->save();
     $this->assertCount(1, $list->getBookListRels());
     $this->assertCount(1, $book->getBookListRels());
     $this->assertCount(1, BookListRelPeer::doSelect(new Criteria()));
     $book->removeBookClubList($list);
     $book->addBookClubList($list);
     $book->save();
     $this->assertCount(1, $list->getBookListRels());
     $this->assertCount(1, $book->getBookListRels());
     $this->assertCount(1, BookListRelPeer::doSelect(new Criteria()));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:24,代码来源:GeneratedObjectRelTest.php

示例8: testSearchMatchesSimilarObjects

 public function testSearchMatchesSimilarObjects()
 {
     $col = new PropelObjectCollection();
     $b1 = new Book();
     $b1->setTitle('Bar');
     $b1->setIsbn('1234');
     $b1->save();
     $b2 = clone $b1;
     $this->assertFalse($col->search($b1), 'search() returns false on an empty collection');
     $col = new PropelObjectCollection(array($b1));
     $this->assertTrue(0 === $col->search($b1));
     $this->assertTrue(0 === $col->search($b2));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:13,代码来源:PropelObjectCollectionTest.php

示例9: testFindOneOrCreateMakesOneQueryWhenRecordExists

 public function testFindOneOrCreateMakesOneQueryWhenRecordExists()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     BookQuery::create()->deleteAll($con);
     $book = new Book();
     $book->setPrice(125);
     $book->setTitle('Title');
     $book->setIsbn('1245');
     $book->save($con);
     $count = $con->getQueryCount();
     $book = BookQuery::create('b')->filterByPrice(125)->findOneOrCreate($con);
     $this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record exists');
 }
开发者ID:ruian,项目名称:Propel,代码行数:13,代码来源:ModelCriteriaTest.php

示例10: testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins

 public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins()
 {
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     BookOpinionPeer::clearInstancePool();
     BookReaderPeer::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->findOne($this->con);
     $this->assertEquals(0, count($books->getBookOpinions()));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:24,代码来源:PropelObjectFormatterWithTest.php

示例11: testFindPkDoesNotCallPreSelectWhenUsingInstancePool

 public function testFindPkDoesNotCallPreSelectWhenUsingInstancePool()
 {
     $b = new Book();
     $b->setTitle('foo');
     $b->setIsbn('1245');
     $b->save();
     $q = new mySecondBookQuery();
     $this->assertFalse($q::$preSelectWasCalled);
     $q->findPk($b->getId());
     $this->assertFalse($q::$preSelectWasCalled);
 }
开发者ID:ruian,项目名称:Propel,代码行数:11,代码来源:QueryBuilderTest.php

示例12: testRemoveObjectOneToManyWithFkRequired

 public function testRemoveObjectOneToManyWithFkRequired()
 {
     BookSummaryQuery::create()->deleteAll();
     BookQuery::create()->deleteAll();
     $bookSummary = new BookSummary();
     $bookSummary->setSummary('summary Propel Book');
     $bookSummary2 = new BookSummary();
     $bookSummary2->setSummary('summary2 Propel Book');
     $book = new Book();
     $book->setTitle('Propel Book');
     $book->setIsbn('1235');
     $book->addBookSummary($bookSummary);
     $book->addBookSummary($bookSummary2);
     $this->assertCount(2, $book->getBookSummarys());
     $book->removeBookSummary($bookSummary);
     $bookSummaries = $book->getBookSummarys();
     $this->assertCount(1, $bookSummaries);
     $this->assertEquals('summary2 Propel Book', reset($bookSummaries)->getSummary());
     $book->save();
     $bookSummary2->save();
     $this->assertEquals(1, BookQuery::create()->count(), 'One Book');
     $this->assertEquals(1, BookSummaryQuery::create()->count(), 'One Summary');
     $this->assertEquals(1, BookSummaryQuery::create()->filterBySummarizedBook($book)->count());
     $book->addBookSummary($bookSummary);
     $bookSummary->save();
     $book->save();
     $this->assertEquals(2, BookSummaryQuery::create()->filterBySummarizedBook($book)->count());
     $book->removeBookSummary($bookSummary2);
     $book->save();
     $this->assertEquals(1, BookSummaryQuery::create()->filterBySummarizedBook($book)->count());
     $this->assertEquals(1, BookSummaryQuery::create()->count(), 'One Book summary because FK is required so book summary is deleted when book is saved');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:32,代码来源:GeneratedObjectRelTest.php

示例13: getBookById

 function getBookById($Bood_Id)
 {
     $book = new Book();
     $this->connect();
     $result = $this->conn->query("CALL sp_search_book_by_book_id('{$Bood_Id}')");
     $obj = $result->fetch_object();
     $book->setBookId($obj->Book_id);
     $book->setTitle($obj->Title);
     $book->setPublisherId($obj->Publisher_id);
     $book->setIsbn($obj->Isbn);
     $book->setCategoryId($obj->Category_id);
     $book->setPublisherName($obj->Publisher_name);
     $book->setCategoryName($obj->Subject);
     $result->close();
     // for fetch_object()
     //$result->free_result(); // for fetch_assoc()
     $this->close();
     return $book;
 }
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:19,代码来源:DBConnection.php

示例14: testFindOneWithOneToManyCustomOrder

 public function testFindOneWithOneToManyCustomOrder()
 {
     $author1 = new Author();
     $author1->setFirstName('AA');
     $author1->setLastName('AA');
     $author2 = new Author();
     $author2->setFirstName('BB');
     $author2->setLastName('BB');
     $book1 = new Book();
     $book1->setTitle('Aaa');
     $book1->setIsbn('124');
     $book1->setAuthor($author1);
     $book1->save();
     $book2 = new Book();
     $book2->setTitle('Bbb');
     $book2->setIsbn('35T');
     $book2->setAuthor($author2);
     $book2->save();
     $book3 = new Book();
     $book3->setTitle('Ccc');
     $book3->setIsbn('1256');
     $book3->setAuthor($author1);
     $book3->save();
     $authors = AuthorQuery::create()->setFormatter(ModelCriteria::FORMAT_ARRAY)->leftJoin('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:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:PropelArrayFormatterWithTest.php

示例15: testSavingParentSavesRelatedObjectsIncludingNew

 public function testSavingParentSavesRelatedObjectsIncludingNew()
 {
     $author = AuthorPeer::retrieveByPK($this->author->getId());
     // add new object before fetching old books
     $b3 = new Book();
     $b3->setIsbn('124');
     $b3->setTitle('Title');
     $author->addBook($b3);
     $c = new Criteria();
     $c->add(BookPeer::ID, $this->books[0]->getId());
     $books = $author->getBooks($c);
     $books[0]->setTitle('Update to a book');
     $author->save();
     $this->assertEquals(3, $author->countBooks());
     $this->assertFalse($b3->isModified());
     $this->assertFalse($books[0]->isModified());
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:17,代码来源:PoisonedCacheBugTest.php


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