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


PHP BookTableMap::clearInstancePool方法代码示例

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


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

示例1: testDelete

 public function testDelete()
 {
     $books = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find();
     $books->delete();
     // check that the modifications are persisted
     BookTableMap::clearInstancePool();
     $books = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->find();
     $this->assertEquals(0, count($books));
 }
开发者ID:badelas,项目名称:thelia,代码行数:9,代码来源:ArrayCollectionTest.php

示例2: testSerializeHydratedObject

 public function testSerializeHydratedObject()
 {
     $book = new Book();
     $book->setTitle('Foo3');
     $book->setISBN('1234');
     $book->save();
     BookTableMap::clearInstancePool();
     $book = BookQuery::create()->findOneByTitle('Foo3');
     $sb = serialize($book);
     $this->assertEquals($book, unserialize($sb));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:11,代码来源:ActiveRecordSerializeTest.php

示例3: testFindOneWithClassAndColumn

 public function testFindOneWithClassAndColumn()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
     $c->filterByTitle('The Tin Drum');
     $c->join('Propel\\Tests\\Bookstore\\Book.Author');
     $c->withColumn('Author.FirstName', 'AuthorName');
     $c->withColumn('Author.LastName', 'AuthorName2');
     $c->with('Author');
     $c->limit(1);
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $books = $c->find($con);
     foreach ($books as $book) {
         break;
     }
     $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class');
     $this->assertEquals('The Tin Drum', $book->getTitle());
     $this->assertTrue($book->getAuthor() instanceof Author, 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'ObjectFormatter adds withColumns as virtual columns');
     $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'ObjectFormatter correctly hydrates all virtual columns');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:OnDemandFormatterWithTest.php

示例4: testPruneCompositeKey

 public function testPruneCompositeKey()
 {
     BookstoreDataPopulator::depopulate();
     BookstoreDataPopulator::populate();
     // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved
     $c = new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book');
     $books = $c->find();
     foreach ($books as $book) {
         $book->save();
     }
     BookTableMap::clearInstancePool();
     $nbBookListRel = BookListRelQuery::create()->prune()->count();
     $this->assertEquals(2, $nbBookListRel, 'prune() does nothing when passed a null object');
     $testBookListRel = BookListRelQuery::create()->findOne();
     $nbBookListRel = BookListRelQuery::create()->prune($testBookListRel)->count();
     $this->assertEquals(1, $nbBookListRel, 'prune() removes an object from the result');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:17,代码来源:QueryBuilderTest.php

示例5: testPopulateRelationOneToManyWithEmptyCollection

 public function testPopulateRelationOneToManyWithEmptyCollection()
 {
     $author = new Author();
     $author->setFirstName('Chuck');
     $author->setLastName('Norris');
     $author->save($this->con);
     AuthorTableMap::clearInstancePool();
     BookTableMap::clearInstancePool();
     $coll = new ObjectCollection();
     $coll->setFormatter(new ObjectFormatter(new ModelCriteria(null, '\\Propel\\Tests\\Bookstore\\Author')));
     $coll[] = $author;
     $books = $coll->populateRelation('Book', null, $this->con);
     $this->assertEquals(0, $books->count());
     $count = $this->con->getQueryCount();
     $this->assertEquals(0, $author->countBooks());
     $this->assertEquals($count, $this->con->getQueryCount());
 }
开发者ID:KyleGoslan,项目名称:Huge-Propel,代码行数:17,代码来源:ObjectCollectionTest.php

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

示例7: testFindPkWithOneToMany

 public function testFindPkWithOneToMany()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $book = BookQuery::create()->findOneByTitle('Harry Potter and the Order of the Phoenix', $con);
     $pk = $book->getPrimaryKey();
     BookTableMap::clearInstancePool();
     $book = BookQuery::create()->setFormatter(ModelCriteria::FORMAT_ARRAY)->joinWith('Review')->findPk($pk, $con);
     $reviews = $book['Reviews'];
     $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated');
 }
开发者ID:badelas,项目名称:thelia,代码行数:14,代码来源:ArrayFormatterWithTest.php

示例8: testSetterOneToManyWithExistingObjects

 public function testSetterOneToManyWithExistingObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     for ($i = 0; $i < 3; $i++) {
         $b = new Book();
         $b->setTitle('Book ' . $i);
         $b->setISBN('FA404-' . $i);
         $b->save();
     }
     BookTableMap::clearInstancePool();
     $books = BookQuery::create()->find();
     $a = new Author();
     $a->setFirstName('Chuck');
     $a->setLastName('Norris');
     $a->setBooks($books);
     $a->save();
     $this->assertEquals(3, count($a->getBooks()));
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(3, BookQuery::create()->count());
     $i = 0;
     foreach ($a->getBooks() as $book) {
         $this->assertEquals('Book ' . $i++, $book->getTitle());
     }
 }
开发者ID:robin850,项目名称:Propel2,代码行数:26,代码来源:GeneratedObjectTest.php

示例9: testToArrayIncludesForeignObjects

 public function testToArrayIncludesForeignObjects()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     PublisherTableMap::clearInstancePool();
     $c = new Criteria();
     $c->add(BookTableMap::COL_TITLE, 'Don Juan');
     $books = BookQuery::create(null, $c)->joinWith('Author')->find();
     $book = $books[0];
     $arr1 = $book->toArray(TableMap::TYPE_PHPNAME, null, array(), true);
     $expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author');
     $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects');
     $this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:15,代码来源:GeneratedObjectWithFixturesTest.php

示例10: testPopulateRelationManyToOne

 public function testPopulateRelationManyToOne()
 {
     $con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME);
     AuthorTableMap::clearInstancePool();
     BookTableMap::clearInstancePool();
     $books = BookQuery::create()->find($con);
     $count = $con->getQueryCount();
     $books->populateRelation('Author', null, $con);
     foreach ($books as $book) {
         $author = $book->getAuthor();
     }
     $this->assertEquals($count + 1, $con->getQueryCount(), 'populateRelation() populates a many-to-one relationship with a single supplementary query');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:ObjectCollectionWithFixturesTest.php

示例11: testSetterCollectionWithExistingObjects

 public function testSetterCollectionWithExistingObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     for ($i = 0; $i < 3; $i++) {
         $b = new Book();
         $b->setTitle('Book ' . $i);
         $b->setIsbn($i);
         $b->save();
     }
     BookTableMap::clearInstancePool();
     $books = BookQuery::create()->find();
     $bookClubList = new BookClubList();
     $bookClubList->setGroupLeader('fabpot');
     $bookClubList->setBooks($books);
     $bookClubList->save();
     $this->assertEquals(3, count($bookClubList->getBooks()));
     $this->assertEquals(3, BookQuery::create()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(3, BookListRelQuery::create()->count());
     $i = 0;
     foreach ($bookClubList->getBooks() as $book) {
         $this->assertEquals('Book ' . $i++, $book->getTitle());
     }
 }
开发者ID:disider,项目名称:Propel2,代码行数:27,代码来源:GeneratedObjectRelTest.php

示例12: testQueryFilter

 public function testQueryFilter()
 {
     $book = new Book();
     $book->setTitle('Book 1');
     $book->setISBN('12313');
     $book->save();
     $author = new Author();
     $author->setFirstName('Steve');
     $author->setLastName('Bla');
     $author->save();
     $bookLog = new PolymorphicRelationLog();
     $bookLog->setMessage('book added');
     $bookLog->setBook($book);
     $bookLog->save();
     $authorLog = new PolymorphicRelationLog();
     $authorLog->setMessage('author added');
     $authorLog->setAuthor($author);
     $authorLog->save();
     PolymorphicRelationLogTableMap::clearInstancePool();
     $foundLog = PolymorphicRelationLogQuery::create()->filterByBook($book)->findOne();
     $this->assertEquals($bookLog->getId(), $foundLog->getId());
     $this->assertEquals('book', $foundLog->getTargetType());
     $this->assertEquals($book, $foundLog->getBook());
     $this->assertNull($foundLog->getAuthor());
     PolymorphicRelationLogTableMap::clearInstancePool();
     $foundLog = PolymorphicRelationLogQuery::create()->filterByAuthor($author)->findOne();
     $this->assertEquals($authorLog->getId(), $foundLog->getId());
     $this->assertEquals('author', $foundLog->getTargetType());
     $this->assertEquals($author, $foundLog->getAuthor());
     $this->assertNull($foundLog->getBook());
     // ref methods
     BookTableMap::clearInstancePool();
     $foundBook = BookQuery::create()->filterByPolymorphicRelationLog($bookLog)->findOne();
     $this->assertEquals($book->getId(), $foundBook->getId());
     BookTableMap::clearInstancePool();
     $foundAuthor = AuthorQuery::create()->filterByPolymorphicRelationLog($bookLog)->findOne();
     $this->assertNull($foundAuthor);
     $foundAuthor = AuthorQuery::create()->filterByPolymorphicRelationLog($authorLog)->findOne();
     $this->assertEquals($author->getId(), $foundAuthor->getId());
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:40,代码来源:BookstoreLoggingTest.php

示例13: testDoSelectJoin

 /**
  * Test the basic functionality of the doSelectJoin*() methods.
  */
 public function testDoSelectJoin()
 {
     BookTableMap::clearInstancePool();
     $c = new Criteria();
     $books = BookQuery::create()->doSelect($c);
     $obj = $books[0];
     // $size = strlen(serialize($obj));
     BookTableMap::clearInstancePool();
     $joinBooks = BookQuery::create()->joinWith('Author')->find();
     $obj2 = $joinBooks[0];
     $obj2Array = $obj2->toArray(TableMap::TYPE_PHPNAME, true, [], true);
     // $joinSize = strlen(serialize($obj2));
     $this->assertEquals(count($books), count($joinBooks), "Expected to find same number of rows in doSelectJoin*() call as doSelect() call.");
     // $this->assertTrue($joinSize > $size, "Expected a serialized join object to be larger than a non-join object.");
     $this->assertTrue(array_key_exists('Author', $obj2Array));
 }
开发者ID:disider,项目名称:Propel2,代码行数:19,代码来源:GeneratedQueryDoSelectTest.php


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