本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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;
}
示例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');
}
示例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();
}
示例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();
}
示例8: tearDown
protected function tearDown()
{
$this->books = null;
parent::tearDown();
Propel::enableInstancePooling();
}
示例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();
}
示例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();
}
示例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();
}
示例12: enablePooling
public function enablePooling()
{
\Propel\Runtime\Propel::enableInstancePooling();
}
示例13: tearDown
protected function tearDown()
{
parent::tearDown();
Propel::enableInstancePooling();
}
示例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');
}
示例15: enableInstancePooling
/**
* @afterClass
*/
public static function enableInstancePooling()
{
Propel::enableInstancePooling();
//Enable it for the other tests
}