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


PHP AuthorPeer::clearInstancePool方法代码示例

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


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

示例1: tearDown

 /**
  * This is run after each unit test.  It empties the database.
  */
 protected function tearDown()
 {
     BookstoreDataPopulator::depopulate();
     $this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect book table to be empty.");
     $this->assertEquals(0, count(AuthorPeer::doSelect(new Criteria())), "Expect author table to be empty.");
     $this->assertEquals(0, count(PublisherPeer::doSelect(new Criteria())), "Expect publisher table to be empty.");
     $this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect review table to be empty.");
     $this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect media table to be empty.");
     $this->assertEquals(0, count(BookstoreEmployeePeer::doSelect(new Criteria())), "Expect bookstore_employee table to be empty.");
     $this->assertEquals(0, count(BookstoreEmployeeAccountPeer::doSelect(new Criteria())), "Expect bookstore_employee_account table to be empty.");
     $this->assertEquals(0, count(BookstoreSalePeer::doSelect(new Criteria())), "Expect bookstore_sale table to be empty.");
     BookPeer::clearInstancePool();
     $this->assertEquals(0, count(BookPeer::$instances), "Expected 0 Book instances after clearInstancePool()");
     AuthorPeer::clearInstancePool();
     $this->assertEquals(0, count(AuthorPeer::$instances), "Expected 0 Author instances after clearInstancePool()");
     PublisherPeer::clearInstancePool();
     $this->assertEquals(0, count(PublisherPeer::$instances), "Expected 0 Publisher instances after clearInstancePool()");
     ReviewPeer::clearInstancePool();
     $this->assertEquals(0, count(ReviewPeer::$instances), "Expected 0 Review instances after clearInstancePool()");
     MediaPeer::clearInstancePool();
     $this->assertEquals(0, count(MediaPeer::$instances), "Expected 0 Media instances after clearInstancePool()");
     BookstoreEmployeePeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreEmployeePeer::$instances), "Expected 0 BookstoreEmployee instances after clearInstancePool()");
     BookstoreEmployeeAccountPeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreEmployeeAccountPeer::$instances), "Expected 0 BookstoreEmployeeAccount instances after clearInstancePool()");
     BookstoreSalePeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreSalePeer::$instances), "Expected 0 BookstoreSale instances after clearInstancePool()");
     parent::tearDown();
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:32,代码来源:BookstoreTestBase.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $a = new Author();
     $a->setFirstName("Douglas");
     $a->setLastName("Adams");
     $b1 = new Book();
     $b1->setTitle("The Hitchhikers Guide To The Galaxy");
     $a->addBook($b1);
     $b2 = new Book();
     $b2->setTitle("The Restaurant At The End Of The Universe");
     $a->addBook($b2);
     $a->save();
     $this->author = $a;
     $this->books = array($b1, $b2);
     Propel::enableInstancePooling();
     // Clear author instance pool so the object would be fetched from the database
     AuthorPeer::clearInstancePool();
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:19,代码来源:PoisonedCacheBugTest.php

示例3: testNestedTransactionForceRollBack

 public function testNestedTransactionForceRollBack()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME);
     // main transaction
     $con->beginTransaction();
     $a = new Author();
     $a->setFirstName('Test');
     $a->setLastName('User');
     $a->save($con);
     $authorId = $a->getId();
     // nested transaction
     $con->beginTransaction();
     $a2 = new Author();
     $a2->setFirstName('Test2');
     $a2->setLastName('User2');
     $a2->save($con);
     $authorId2 = $a2->getId();
     // force rollback
     $con->forceRollback();
     $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is null after nested transaction forced rollback');
     $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after nested transaction force rollback');
     AuthorPeer::clearInstancePool();
     $at = AuthorPeer::retrieveByPK($authorId);
     $this->assertNull($at, "Rolled back transaction is not persisted in database");
     $at2 = AuthorPeer::retrieveByPK($authorId2);
     $this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database");
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:28,代码来源:PropelPDOTest.php

示例4: testFindPkWithOneToMany

 public function testFindPkWithOneToMany()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     ReviewPeer::clearInstancePool();
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $book = BookQuery::create()->findOneByTitle('Harry Potter and the Order of the Phoenix', $con);
     $pk = $book->getPrimaryKey();
     BookPeer::clearInstancePool();
     $book = BookQuery::create()->joinWith('Review')->findPk($pk, $con);
     $count = $con->getQueryCount();
     $reviews = $book->getReviews();
     $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ');
     $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated');
 }
开发者ID:halfer,项目名称:Meshing,代码行数:16,代码来源:PropelObjectFormatterWithTest.php

示例5: testFindOneWithClassAndColumn

 public function testFindOneWithClassAndColumn()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     ReviewPeer::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Book');
     $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
     $c->filterByTitle('The Tin Drum');
     $c->join('Book.Author');
     $c->withColumn('Author.FirstName', 'AuthorName');
     $c->withColumn('Author.LastName', 'AuthorName2');
     $c->with('Author');
     $c->limit(1);
     $con = Propel::getConnection(BookPeer::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, 'PropelObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns');
     $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:PropelOnDemandFormatterWithTest.php

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

示例7: clearCache

 function clearCache()
 {
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:5,代码来源:Propel17TestSuite.php

示例8: testRefFKGetJoin

 public function testRefFKGetJoin()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     PublisherPeer::clearInstancePool();
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $author = AuthorPeer::doSelectOne(new Criteria(), $con);
     // populate book instance pool
     $books = $author->getBooksJoinPublisher(null, $con);
     $sql = $con->getLastExecutedQuery();
     $publisher = $books[0]->getPublisher($con);
     $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:GeneratedObjectRelTest.php

示例9: testRollBack_NestedSwallow

 /**
  * @link       http://propel.phpdb.org/trac/ticket/699
  */
 public function testRollBack_NestedSwallow()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME);
     if ($driver == "mysql") {
         $this->markTestSkipped();
     }
     $con->beginTransaction();
     try {
         $a = new Author();
         $a->setFirstName('Test');
         $a->setLastName('User');
         $a->save($con);
         $authorId = $a->getId();
         $this->assertTrue($authorId !== null, "Expected valid new author ID");
         $con->beginTransaction();
         try {
             $con->exec('INVALID SQL');
             $this->fail("Expected exception on invalid SQL");
         } catch (Exception $x) {
             $con->rollBack();
             // NO RETHROW
         }
         $a2 = new Author();
         $a2->setFirstName('Test2');
         $a2->setLastName('User2');
         $authorId2 = $a2->save($con);
         $con->commit();
         // this should not do anything!
     } catch (Exception $x) {
         $this->fail("No outside rollback expected.");
     }
     AuthorPeer::clearInstancePool();
     $at = AuthorPeer::retrieveByPK($authorId);
     $this->assertNull($at, "Expected no author result for rolled-back save.");
     $at2 = AuthorPeer::retrieveByPK($authorId2);
     $this->assertNull($at2, "Expected no author2 result for rolled-back save.");
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:41,代码来源:PropelPDOTest.php

示例10: testPopulateRelationOneToManyWithEmptyCollection

 public function testPopulateRelationOneToManyWithEmptyCollection()
 {
     $author = new Author();
     $author->setLastName('I who never wrote');
     $author->save($this->con);
     AuthorPeer::clearInstancePool();
     BookPeer::clearInstancePool();
     $coll = new PropelObjectCollection();
     $coll->setFormatter(new PropelObjectFormatter(new ModelCriteria(null, '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:keneanung,项目名称:gw2spidy,代码行数:16,代码来源:PropelObjectCollectionTest.php

示例11: doDelete

 /**
  * Method perform a DELETE on the database, given a Author or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or Author object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(AuthorPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         AuthorPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof Author) {
         // it's a model object
         // invalidate the cache for this single object
         AuthorPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(AuthorPeer::ID, (array) $values, Criteria::IN);
         // invalidate the cache for this object(s)
         foreach ((array) $values as $singleval) {
             AuthorPeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         AuthorPeer::clearRelatedInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
开发者ID:redandpink,项目名称:h-emergenze,代码行数:55,代码来源:BaseAuthorPeer.php

示例12: doDelete

 /**
  * Performs a DELETE on the database, given a Author or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or Author object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(AuthorPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof Author) {
         // it's a model object
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(AuthorPeer::DATABASE_NAME);
         $criteria->add(AuthorPeer::ID, (array) $values, Criteria::IN);
     }
     // Set the correct dbName
     $criteria->setDbName(AuthorPeer::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
         $c = clone $criteria;
         AuthorPeer::doOnDeleteSetNull($c, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             AuthorPeer::clearInstancePool();
         } elseif ($values instanceof Author) {
             // it's a model object
             AuthorPeer::removeInstanceFromPool($values);
         } else {
             // it's a primary key, or an array of pks
             foreach ((array) $values as $singleval) {
                 AuthorPeer::removeInstanceFromPool($singleval);
             }
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         AuthorPeer::clearRelatedInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:62,代码来源:BaseAuthorPeer.php

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

示例14: testPopulateRelationManyToOne

 public function testPopulateRelationManyToOne()
 {
     $con = Propel::getConnection();
     AuthorPeer::clearInstancePool();
     BookPeer::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:keneanung,项目名称:gw2spidy,代码行数:13,代码来源:PropelObjectCollectionWithFixturesTest.php

示例15: testToArrayIncludeForeignObjects

 public function testToArrayIncludeForeignObjects()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     PublisherPeer::clearInstancePool();
     $c = new Criteria();
     $c->add(BookPeer::TITLE, 'Don Juan');
     $books = BookPeer::doSelectJoinAuthor($c);
     $book = $books[0];
     $arr1 = $book->toArray(BasePeer::TYPE_PHPNAME, null, 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');
     $c = new Criteria();
     $c->add(BookPeer::TITLE, 'Don Juan');
     $books = BookPeer::doSelectJoinAll($c);
     $book = $books[0];
     $arr2 = $book->toArray(BasePeer::TYPE_PHPNAME, null, true);
     $expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Publisher', 'Author');
     $this->assertEquals($expectedKeys, array_keys($arr2), 'toArray() can return sub arrays for hydrated related objects');
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:22,代码来源:GeneratedObjectTest.php


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