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


PHP Book::setIsbn方法代码示例

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


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

示例1: testSetterCollection

 public function testSetterCollection()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     $books = new ObjectCollection();
     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:rouffj,项目名称:Propel2,代码行数:83,代码来源:GeneratedObjectRelTest.php

示例2: testSetterOneToMany

 public function testSetterOneToMany()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $coll = new ObjectCollection();
     $coll->setModel('\\Propel\\Tests\\Bookstore\\Book');
     for ($i = 0; $i < 3; $i++) {
         $b = new Book();
         $b->setTitle('Title ' . $i);
         $b->setISBN($i);
         $coll[] = $b;
     }
     $this->assertEquals(3, $coll->count());
     $a = new Author();
     $a->setFirstName('Chuck');
     $a->setLastName('Norris');
     $a->setBooks($coll);
     $a->save();
     $this->assertInstanceOf('\\Propel\\Runtime\\Collection\\ObjectCollection', $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());
     //The book is not deleted because his fk is not required
     $this->assertEquals(3, 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(4, 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(5, 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(5, BookQuery::create()->count());
 }
开发者ID:robin850,项目名称:Propel2,代码行数:64,代码来源:GeneratedObjectTest.php

示例3: 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

示例4: testSetterCollectionWithCustomNamedFKs

 public function testSetterCollectionWithCustomNamedFKs()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     BookListFavoriteQuery::create()->deleteAll();
     $books = new ObjectCollection();
     foreach (['foo', 'bar', 'test'] as $title) {
         $b = new Book();
         $b->setTitle($title);
         $b->setIsbn('FA404');
         $books[] = $b;
     }
     $bookClubList = new BookClubList();
     $bookClubList->setGroupLeader('fabpot');
     $bookClubList->setFavoriteBooks($books);
     $bookClubList->save();
     $bookClubList->reload(true);
     $this->assertCount(3, $bookClubList->getFavoriteBooks());
     $bookClubList->reload(true);
     $books->shift();
     $bookClubList->setFavoriteBooks($books);
     $bookClubList->save();
     $bookClubList->reload(true);
     $this->assertCount(2, $bookClubList->getFavoriteBooks());
 }
开发者ID:disider,项目名称:Propel2,代码行数:27,代码来源:GeneratedObjectRelTest.php


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