當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Propel::enableInstancePooling方法代碼示例

本文整理匯總了PHP中Propel\Runtime\Propel::enableInstancePooling方法的典型用法代碼示例。如果您正苦於以下問題:PHP Propel::enableInstancePooling方法的具體用法?PHP Propel::enableInstancePooling怎麽用?PHP Propel::enableInstancePooling使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Runtime\Propel的用法示例。


在下文中一共展示了Propel::enableInstancePooling方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: closeCursor

 public function closeCursor()
 {
     $this->dataFetcher->close();
     if ($this->enableInstancePoolingOnFinish) {
         Propel::enableInstancePooling();
     }
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:7,代碼來源:OnDemandIterator.php

示例2: testInstancePoolingReenabled

 public function testInstancePoolingReenabled()
 {
     Propel::enableInstancePooling();
     $books = PropelQuery::from('\\Propel\\Tests\\Bookstore\\Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertTrue(Propel::isInstancePoolingEnabled());
     Propel::disableInstancePooling();
     $books = PropelQuery::from('\\Propel\\Tests\\Bookstore\\Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertFalse(Propel::isInstancePoolingEnabled());
     Propel::enableInstancePooling();
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:14,代碼來源:OnDemandIteratorTest.php

示例3: 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
     AuthorTableMap::clearInstancePool();
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:19,代碼來源:PoisonedCacheBugTest.php

示例4: execute

 /**
  * Populate the database using all the Entity classes previously added.
  *
  * @param PropelPDO $con A Propel connection object
  *
  * @return array A list of the inserted PKs
  */
 public function execute($con = null)
 {
     if (null === $con) {
         $con = $this->getConnection();
     }
     $isInstancePoolingEnabled = Propel::isInstancePoolingEnabled();
     Propel::disableInstancePooling();
     $insertedEntities = array();
     $con->beginTransaction();
     foreach ($this->quantities as $class => $number) {
         for ($i = 0; $i < $number; $i++) {
             $insertedEntities[$class][] = $this->entities[$class]->execute($con, $insertedEntities);
         }
     }
     $con->commit();
     if ($isInstancePoolingEnabled) {
         Propel::enableInstancePooling();
     }
     return $insertedEntities;
 }
開發者ID:lyrasoft,項目名稱:lyrasoft.github.io,代碼行數:27,代碼來源:Populator.php

示例5: testFindPkCompositeKey

 public function testFindPkCompositeKey()
 {
     BookstoreDataPopulator::depopulate();
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\BookListRel');
     $bookListRel = $c->findPk(array(1, 2));
     $this->assertNull($bookListRel, 'findPk() returns null when the composite primary key is not found');
     Propel::enableInstancePooling();
     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();
     }
     // retrieve the test data
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\BookListRel');
     $bookListRelTest = $c->findOne();
     $pk = $bookListRelTest->getPrimaryKey();
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\BookListRel');
     $bookListRel = $c->findPk($pk);
     $this->assertEquals($bookListRelTest, $bookListRel, 'findPk() can find objects with composite primary keys');
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:22,代碼來源:ModelCriteriaTest.php

示例6: testUpdateDefaultAddress

 /**
  * Bug found in Thelia 2.0.2
  */
 public function testUpdateDefaultAddress()
 {
     /**
      * Disable propel cache in order to get a new instance of the
      * active record in $updatedAddress
      */
     Propel::disableInstancePooling();
     /**
      * Get a customer and it's default address
      */
     $customer = CustomerQuery::create()->findOne();
     $defaultAddress = $customer->getDefaultAddress();
     $addressId = $defaultAddress->getId();
     /**
      * Try to update the address, and set the isDefault argument,
      * that should keep this address as the default one.
      */
     $addressEvent = new AddressCreateOrUpdateEvent("", 1, "Thelia modif", "Thelia modif", "cour des étoiles", "rue des miracles", "", "63000", "clermont-ferrand", 64, "0102030405", "", "", 1);
     $addressEvent->setAddress($defaultAddress);
     $addressEvent->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface"));
     /**
      * Do the update
      */
     $actionAddress = new Address();
     $actionAddress->update($addressEvent);
     $updatedAddress = AddressQuery::create()->findPk($addressId);
     /**
      * This address should still be the default address
      */
     $this->assertEquals(1, $updatedAddress->getIsDefault());
     /**
      * Renable it after
      */
     Propel::enableInstancePooling();
 }
開發者ID:fachriza,項目名稱:thelia,代碼行數:38,代碼來源:AddressTest.php

示例7: testFormatALotOfResults

 public function testFormatALotOfResults()
 {
     $nbBooks = 50;
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     Propel::disableInstancePooling();
     $book = new Book();
     for ($i = 0; $i < $nbBooks; $i++) {
         $book->clear();
         $book->setTitle('BookTest' . $i);
         $book->setISBN('FA404-' . $i);
         $book->save($con);
     }
     $stmt = $con->query('SELECT * FROM book');
     $formatter = new OnDemandFormatter();
     $formatter->init(new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'));
     $books = $formatter->format($stmt);
     $this->assertTrue($books instanceof OnDemandCollection, 'OnDemandFormatter::format() returns a PropelOnDemandCollection');
     $this->assertEquals($nbBooks, count($books), 'OnDemandFormatter::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, 'OnDemandFormatter::format() returns a collection of Model objects');
         $this->assertEquals('BookTest' . $i, $book->getTitle(), 'OnDemandFormatter::format() returns the model objects matching the query');
         $i++;
     }
     Propel::enableInstancePooling();
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:26,代碼來源:OnDemandFormatterTest.php

示例8: tearDown

 protected function tearDown()
 {
     $this->books = null;
     parent::tearDown();
     Propel::enableInstancePooling();
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:6,代碼來源:OnDemandCollectionTest.php

示例9: testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrectClass

 public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrectClass()
 {
     Propel::disableInstancePooling();
     $manager = new DistributionManager();
     $manager->setName('manager1');
     $manager->save();
     $distributionStore = new DistributionStore();
     $distributionStore->setName('my store 1');
     $distributionStore->setDistributionManager($manager);
     $distributionStore->save();
     $distributionVirtualStore = new DistributionVirtualStore();
     $distributionVirtualStore->setName('my VirtualStore 1');
     $distributionVirtualStore->setDistributionManager($manager);
     $distributionVirtualStore->save();
     $this->assertInstanceOf('Propel\\Tests\\Bookstore\\DistributionStore', DistributionQuery::create()->findPk($distributionStore->getId()), 'findPk() return right object : DistributionStore');
     $this->assertInstanceOf('Propel\\Tests\\Bookstore\\DistributionVirtualStore', DistributionQuery::create()->findPk($distributionVirtualStore->getId()), 'findPk() return right object : DistributionVirtualStore');
     Propel::enableInstancePooling();
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:18,代碼來源:QueryBuilderInheritanceTest.php

示例10: testParamConvertWithOptionWith

 public function testParamConvertWithOptionWith()
 {
     $this->loadFixtures();
     $paramConverter = new PropelParamConverter();
     $request = new Request(array(), array(), array('id' => 1, 'book' => null));
     $configuration = new ParamConverter(array('class' => 'Propel\\Bundle\\PropelBundle\\Tests\\Request\\ParamConverter\\MyBook', 'name' => 'book', 'options' => array('with' => 'MyAuthor')));
     $nb = $this->con->getQueryCount();
     $paramConverter->apply($request, $configuration);
     $book = $request->attributes->get('book');
     $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Tests\\Request\\ParamConverter\\MyBook', $book, 'param "book" should be an instance of "Propel\\Bundle\\PropelBundle\\Tests\\Request\\ParamConverter\\MyBook"');
     $this->assertEquals($nb + 1, $this->con->getQueryCount(), 'only one query to get the book');
     $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Tests\\Request\\ParamConverter\\MyAuthor', $book->getMyAuthor(), 'param "book" should be an instance of "Propel\\Bundle\\PropelBundle\\Tests\\Request\\ParamConverter\\MyAuthor"');
     $this->assertEquals($nb + 1, $this->con->getQueryCount(), 'no new query to get the author');
     Propel::enableInstancePooling();
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:15,代碼來源:PropelParamConverterTest.php

示例11: testHydrateOverwritePreviousValues

    public function testHydrateOverwritePreviousValues()
    {
        $schema = <<<EOF
<database name="generated_object_complex_type_test_with_constructor" namespace="MyNameSpace">
  <table name="complex_column_type_entity_with_constructor">
    <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
    <column name="tags" type="ARRAY" />
  </table>
</database>
EOF;
        QuickBuilder::buildSchema($schema);
        Propel::disableInstancePooling();
        // need to be disabled to test the hydrate() method
        $obj = new ComplexColumnTypeEntityWithConstructor();
        $this->assertEquals(array('foo', 'bar'), $obj->getTags());
        $obj->setTags(array('baz'));
        $this->assertEquals(array('baz'), $obj->getTags());
        $obj->save();
        $obj = ComplexColumnTypeEntityWithConstructorQuery::create()->findOne();
        $this->assertEquals(array('baz'), $obj->getTags());
        Propel::enableInstancePooling();
    }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:22,代碼來源:GeneratedObjectArrayColumnTypeTest.php

示例12: enablePooling

 public function enablePooling()
 {
     \Propel\Runtime\Propel::enableInstancePooling();
 }
開發者ID:a-melnichuk,項目名稱:Movies-Demo,代碼行數:4,代碼來源:LocalWebTestCase.php

示例13: tearDown

 protected function tearDown()
 {
     parent::tearDown();
     Propel::enableInstancePooling();
 }
開發者ID:rouffj,項目名稱:Propel2,代碼行數:5,代碼來源:OnDemandCollectionTest.php

示例14: testDoSelectJoinOneToOne

 public function testDoSelectJoinOneToOne()
 {
     $con = Propel::getServiceContainer()->getReadConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME);
     $count = $con->getQueryCount();
     Propel::disableInstancePooling();
     $c = new Criteria();
     $accs = BookstoreEmployeeAccountPeer::doSelectJoinBookstoreEmployee($c, $con);
     Propel::enableInstancePooling();
     $this->assertEquals(1, $con->getQueryCount() - $count, 'doSelectJoin() makes only one query in a one-to-one relationship');
 }
開發者ID:rouffj,項目名稱:Propel2,代碼行數:10,代碼來源:GeneratedPeerDoSelectTest.php

示例15: enableInstancePooling

 /**
  * @afterClass
  */
 public static function enableInstancePooling()
 {
     Propel::enableInstancePooling();
     //Enable it for the other tests
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:8,代碼來源:ObjectCollectionTest.php


注:本文中的Propel\Runtime\Propel::enableInstancePooling方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。