本文整理汇总了PHP中Propel\Runtime\Propel::disableInstancePooling方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::disableInstancePooling方法的具体用法?PHP Propel::disableInstancePooling怎么用?PHP Propel::disableInstancePooling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Propel
的用法示例。
在下文中一共展示了Propel::disableInstancePooling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFormatALotOfResults
public function testFormatALotOfResults()
{
$nbBooks = 50;
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
Propel::disableInstancePooling();
$book = new Book();
for ($i = 0; $i < $nbBooks; $i++) {
$book->clear();
$book->setTitle('BookTest' . $i);
$book->save($con);
}
$stmt = $con->query('SELECT * FROM book');
$formatter = new PropelOnDemandFormatter();
$formatter->init(new ModelCriteria('bookstore', 'Book'));
$books = $formatter->format($stmt);
$this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection');
$this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::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, 'PropelOnDemandFormatter::format() returns a collection of Model objects');
$this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query');
$i++;
}
Propel::enableInstancePooling();
}
示例2: __construct
/**
* @param AbstractFormatter $formatter
* @param DataFetcherInterface $dataFetcher
*/
public function __construct(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher)
{
$this->currentKey = -1;
$this->formatter = $formatter;
$this->dataFetcher = $dataFetcher;
$this->enableInstancePoolingOnFinish = Propel::disableInstancePooling();
}
示例3: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate($this->con);
Propel::disableInstancePooling();
$this->books = PropelQuery::from('\\Propel\\Tests\\Bookstore\\Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
}
示例4: boot
public function boot()
{
parent::boot();
$this->configure();
if (function_exists('ppm_log')) {
//In an environment like PPM with several workers Propel's not distributed cache will
//lead to inconsistent states across all workers, so we need to disable it here completely.
//Jarves already caches using a distributed cache where all workers are notified when
//a change changes, so we don't really need Propel's cache here.
Propel::disableInstancePooling();
}
if (!$this->booted) {
/** @var ContainerInterface $container */
$container = $this->container;
/** @var $jarves Jarves */
$jarves = $container->get('jarves');
/** @var JarvesConfig $jarvesConfig */
$jarvesConfig = $container->get('jarves.config');
$twig = $container->get('twig');
$twig->addGlobal('jarves_content_render', $container->get('jarves.content.render'));
$twig->addGlobal('pageStack', $container->get('jarves.page_stack'));
if ($jarvesConfig->getSystemConfig()->getLogs(true)->isActive()) {
/** @var $logger \Symfony\Bridge\Monolog\Logger */
$logger = $container->get('logger');
$logger->pushHandler($container->get('jarves.logger.handler'));
}
}
$this->booted = true;
}
示例5: initialize
function initialize()
{
$loader = (require_once __DIR__ . '/../propel_20/vendor/autoload.php');
include realpath(dirname(__FILE__) . '/build/conf/config.php');
$loader->add('', __DIR__ . '/build/classes');
\Propel\Runtime\Propel::disableInstancePooling();
$this->con = \Propel\Runtime\Propel::getConnection('bookstore');
$this->initTables();
}
示例6: 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();
}
示例7: 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;
}
示例8: initialization
public function initialization()
{
Propel::disableInstancePooling();
Propel::getConnection('default');
}
示例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: __construct
/**
* @param PropelFormatter $formatter
* @param PDOStatement $stmt
*/
public function __construct(PropelFormatter $formatter, PDOStatement $stmt)
{
$this->formatter = $formatter;
$this->stmt = $stmt;
$this->enableInstancePoolingOnFinish = Propel::disableInstancePooling();
}
示例11: testFindOneWithoutUsingInstancePool
public function testFindOneWithoutUsingInstancePool()
{
BookstoreDataPopulator::populate();
Propel::disableInstancePooling();
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$c->orderBy('Propel\\Tests\\Bookstore\\Book.Title');
$c->join('Propel\\Tests\\Bookstore\\Book.Author');
$c->with('Author');
$c->join('Propel\\Tests\\Bookstore\\Book.Publisher');
$c->with('Publisher');
$this->assertCorrectHydration1($c, 'without instance pool');
Propel::enableInstancePooling();
}
示例12: onMessage
public function onMessage(ConnectionInterface $from, $msg)
{
$event = $from->event = 'anonymous';
$data = [];
// if message did not exist then deny access
if (!isset($msg) || $msg == '') {
throw new Exception('Wrong turn buddy');
}
// if event or data did not exist then deny access
$msg = json_decode($msg);
if (!$msg || !isset($msg->event) || !isset($msg->data)) {
throw new Exception('Wrong turn buddy');
}
// store baby store em to variables
$event = $from->event = $msg->event;
$params = $msg->data;
// if user not loged in yet then deny access
if ($from->Session->get('pos/state') != 1) {
throw new Exception('Akses ditolak. Anda belum login.');
}
// initiating propel orm
require_once 'propel-config.php';
Propel::disableInstancePooling();
$con = Propel::getConnection('pos');
// if user don't have role assigned then deny access
$role = RoleQuery::create()->findOneById($from->Session->get('pos/current_user')->role_id);
if (!$role) {
throw new Exception('Akses ditolak. Anda belum punya Jabatan.');
}
// uh... decoding event to get requested module and method
$decode = explode('/', $event);
// if decoded array length is not 2 then deny access
if (count($decode) != 2) {
throw new Exception('Wrong turn buddy');
}
// store baby store em to variables... again
$module = $decode[0];
$method = $decode[1];
// list of all module that can be requested
$registeredModule = array('chart', 'combo', 'credit', 'customer', 'debit', 'notification', 'option', 'populate', 'product', 'purchase', 'report', 'role', 'sales', 'secondParty', 'stock', 'supplier', 'unit', 'user');
// if requested module is not registered then deny access
if (!in_array($module, $registeredModule)) {
throw new Exception('Wrong turn buddy');
}
// you know it.. begin transaction
$con->beginTransaction();
// this is where magic begins..
// route to requested module
$data = $this->{$module}($method, $params, $from, $con);
// commit transaction
$con->commit();
// store to results variable before spitting it out back to client
$results['event'] = $event;
$results['data'] = $data;
// errmmmmm
$from->send(json_encode($results));
// followup action
if ($event == 'purchase/create' || $event == 'purchase/destroy' || $event == 'purchase/update') {
// get update of last 30 Days transaction's data
$data = $this->chart('last30DaysTransaction', new \stdClass(), $from, $con);
$last30DaysTransaction['event'] = 'chart/last30DaysTransaction';
$last30DaysTransaction['data'] = $data;
// iterate through all connected client
foreach ($this->clients as $client) {
// get notification update of each client
$data = $this->notification('read', new \stdClass(), $client, $con);
$results['event'] = 'notification/read';
$results['data'] = $data;
// push notification to each client
$client->send(json_encode($results));
// push last 30 Days transaction's data to each client
$client->send(json_encode($last30DaysTransaction));
}
} elseif ($event == 'sales/create' || $event == 'sales/destroy' || $event == 'sales/update') {
// get update of last 30 Days transaction's data
$data = $this->chart('last30DaysTransaction', new \stdClass(), $from, $con);
$last30DaysTransaction['event'] = 'chart/last30DaysTransaction';
$last30DaysTransaction['data'] = $data;
// iterate through all connected client
foreach ($this->clients as $client) {
// push last 30 Days transaction's data to each client
$client->send(json_encode($last30DaysTransaction));
}
}
// finish
return;
}
示例13: 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();
}
示例14: disablePooling
public function disablePooling()
{
\Propel\Runtime\Propel::disableInstancePooling();
}
示例15: 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');
}