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


PHP Propel::enableInstancePooling方法代码示例

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


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

示例1: next

 /**
  * Advances the curesor in the statement
  * Closes the cursor if the end of the statement is reached
  */
 public function next()
 {
     $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM);
     $this->currentKey++;
     $this->isValid = (bool) $this->currentRow;
     if (!$this->isValid) {
         $this->closeCursor();
         if ($this->enableInstancePoolingOnFinish) {
             Propel::enableInstancePooling();
         }
     }
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:16,代码来源:PropelOnDemandIterator.php

示例2: testInstancePoolingReenabled

 public function testInstancePoolingReenabled()
 {
     Propel::enableInstancePooling();
     $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertTrue(Propel::isInstancePoolingEnabled());
     Propel::disableInstancePooling();
     $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertFalse(Propel::isInstancePoolingEnabled());
     Propel::enableInstancePooling();
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:14,代码来源:PropelOnDemandIteratorTest.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
     AuthorPeer::clearInstancePool();
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:19,代码来源:PoisonedCacheBugTest.php

示例4: initialize

 /**
  * Configures a Propel datasource.
  *
  * @param array  $parameters The datasource parameters
  * @param string $name       The datasource name
  */
 public function initialize($parameters = null, $name = 'propel')
 {
     parent::initialize($parameters);
     if (!$this->hasParameter('datasource') && $this->hasParameter('name')) {
         $this->setParameter('datasource', $this->getParameter('name'));
     } elseif (!$this->hasParameter('datasource') && !empty($name)) {
         $this->setParameter('datasource', $name);
     }
     $this->addConfig();
     // mark the first connection as the default
     if (!Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->getParameter('datasources.default')) {
         $this->setDefaultConfig();
     }
     // for BC
     if ($this->getParameter('pooling', false)) {
         Propel::enableInstancePooling();
     } else {
         Propel::disableInstancePooling();
     }
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:26,代码来源:sfPropelDatabase.class.php

示例5: 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:ncuesta,项目名称:Faker,代码行数:27,代码来源:Populator.php

示例6: testAdd

    /**
    * Test that PropelCollection->add() prevents duplicates of objects strictly identical
    *
    */
   public function testAdd()
    {
        Propel::disableInstancePooling();
        $eleve1 = EleveQuery::create()->findOneByLogin('Florence Michu');
        $eleve1->setNom('test_different');
        $eleve_col = new PropelCollection();
        $eleve_col->add($eleve1);
        $eleve1idem = EleveQuery::create()->findOneByLogin('Florence Michu');
        $this->assertFalse($eleve_col->contains($eleve1idem));
        $eleve_col->add($eleve1idem);
        $this->assertEquals(2, count($eleve_col));
        Propel::enableInstancePooling();


        $eleve1 = EleveQuery::create()->findOneByLogin('Florence Michu');
        $eleve_col = new PropelCollection();
        $eleve_col->add($eleve1);
        $eleve_col->add($eleve1);
        $this->assertEquals(1, count($eleve_col));
    }
开发者ID:rhertzog,项目名称:lcs,代码行数:24,代码来源:PropelCollectionTest.php

示例7: initialize

 /**
  * Initializes sfPropelDatabase by loading configuration and initializing Propel
  *
  * @param array $parameters The datasource parameters
  * @param string $name The datasource name
  *
  * @return void
  */
 public function initialize($parameters = null, $name = 'propel')
 {
     parent::initialize($parameters);
     if (!$this->hasParameter('datasource') && $this->hasParameter('name')) {
         $this->setParameter('datasource', $this->getParameter('name'));
     } elseif (!$this->hasParameter('datasource') && !empty($name)) {
         $this->setParameter('datasource', $name);
     }
     $this->addConfig();
     $is_default = $this->getParameter('is_default', false);
     // first defined if none listed as default
     if ($is_default || 1 == count(self::$config['propel']['datasources'])) {
         $this->setDefaultConfig();
     }
     Propel::setConfiguration(self::$config[$name]);
     if ($this->getParameter('pooling', false)) {
         Propel::enableInstancePooling();
     } else {
         Propel::disableInstancePooling();
     }
     if (!Propel::isInit()) {
         Propel::initialize();
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:32,代码来源:sfPropelDatabase.class.php

示例8: close

 public function close(array $errors = array(), PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::ID, $this->getId());
     $c->addJoin(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     $c->addJoin(StudentPeer::ID, StudentCareerSchoolYearPeer::STUDENT_ID);
     //$c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::IN_COURSE);
     $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, false);
     $c->setDistinct(StudentPeer::ID);
     sfConfig::set('sf_logging_enabled', FALSE);
     $cant = 0;
     try {
         $pager = new sfPropelPager('Student', 500);
         $pager->setCriteria($c);
         $pager->init();
         $last_page = $pager->getLastPage();
         for ($i = 1; $i <= $last_page; $i++) {
             $pager->setPage($i);
             $pager->init();
             $students = $pager->getResults();
             $con->beginTransaction();
             Propel::disableInstancePooling();
             foreach ($students as $student) {
                 $cant++;
                 $student_errors = $student->getErrorsWithCourseSubjectsStudent($this);
                 //si el alumno tiene errores guardo el error y sigo evaluando a los demas alumnos
                 if (!empty($student_errors)) {
                     $errors[$student->getId()] = $student_errors;
                     if (count($errors) > sfConfig::get('app_close_course_subject_schol_year_max_error')) {
                         throw new Exception('Maximo de errores alcanzado >' . sfConfig::get('app_close_course_subject_schol_year_max_error'));
                     }
                 } else {
                     $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $this);
                     //si el alumno tiene reserva de banco no deberia hacer nada.
                     if ($student_career_school_year->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE) {
                         $student->closeCareerSchoolYear($this, $con);
                         $student_career_school_year->setIsProcessed(true);
                         $student_career_school_year->save($con);
                         $student_career_school_year->clearAllReferences(true);
                         unset($student_career_school_year);
                     }
                 }
                 ####Liberando memoria###
                 $student->clearAllReferences(true);
                 unset($student_errors);
                 unset($student);
                 ##################*/
             }
             ####Liberando memoria###
             StudentPeer::clearInstancePool();
             unset($students);
             ##############################
             $con->commit();
         }
         if (count($errors)) {
             throw new Exception('Hay errores no se puede cerrar el año!');
         }
         //Se setea a la carrera como procesada.
         $this->setIsProcessed(true);
         $this->save($con);
         Propel::enableInstancePooling();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
     return true;
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:68,代码来源:CareerSchoolYear.php

示例9: testHydrateOverwritePreviousValues

    public function testHydrateOverwritePreviousValues()
    {
        $schema = <<<EOF
<database name="generated_object_complex_type_test_with_constructor">
    <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;
        $builder = new PropelQuickBuilder();
        $builder->setSchema($schema);
        $builder->setClassTargets(array('tablemap', 'peer', 'object', 'query', 'peerstub', 'querystub'));
        $builder->build();
        require_once dirname(__FILE__) . '/fixtures/ComplexColumnTypeEntityWithConstructor.php';
        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:kcornejo,项目名称:estadistica,代码行数:26,代码来源:GeneratedObjectArrayColumnTypeTest.php

示例10: convertJob

 /**
  * Do converting
  * @param KalturaConvertJobData $data Job data
  * @return array Result of converting
  */
 public function convertJob(KalturaConvertJobData &$data)
 {
     $outputParams = $data->flavorParamsOutput;
     $videoCodec = $outputParams->videoCodec;
     $videoBitrate = $outputParams->videoBitrate;
     $width = $outputParams->width;
     $height = $outputParams->height;
     $presetName = $outputParams->name;
     $preset = array();
     $preset[kWAMS::CONVERT_PARAM_PRESET_NAME] = $outputParams->name;
     $preset[kWAMS::CONVERT_PARAM_AUDIO_CODEC] = $outputParams->audioCodec;
     $preset[kWAMS::CONVERT_PARAM_AUDIO_BITRATE] = $outputParams->audioBitrate;
     $preset[kWAMS::CONVERT_PARAM_AUDIO_CHANNELS] = $outputParams->audioChannels;
     $preset[kWAMS::CONVERT_PARAM_AUDIO_SAMPLE_RATE] = $outputParams->audioSampleRate;
     $preset[kWAMS::CONVERT_PARAM_VIDEO_CODEC] = $outputParams->videoCodec;
     $preset[kWAMS::CONVERT_PARAM_VIDEO_WIDTH] = $outputParams->width;
     $preset[kWAMS::CONVERT_PARAM_VIDEO_HEIGHT] = $outputParams->height;
     $preset[kWAMS::CONVERT_PARAM_VIDEO_BITRATE] = $outputParams->videoBitrate;
     KalturaLog::debug("Video params output: preset = [{$presetName}], videoCodec = [{$videoCodec}], videoBitrate = [{$videoBitrate}], width = [{$width}], height = [{$height}]");
     $start = microtime(true);
     $kWAMS = kWAMS::getInstance($data->flavorParamsOutput->partnerId);
     $wamsJobId = $kWAMS->addConvertJob($data->srcFileSyncWamsAssetId, $preset);
     Propel::disableInstancePooling();
     while ($kWAMS->isJobProcessing($wamsJobId)) {
         // check Kaltura Batch Job Status
         if (BatchJobPeer::retrieveByPK($this->batchJobId)->getAbort()) {
             $kWAMS->cancelJob($wamsJobId);
         }
         sleep(5);
     }
     Propel::enableInstancePooling();
     $data->destFileSyncWamsAssetId = $kWAMS->getOutputAssetId($wamsJobId);
     $end = microtime(true);
     $duration = $end - $start;
     KalturaLog::info($this->getName() . ":  took [{$duration}] seconds");
     return array(true, null);
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:42,代码来源:KConversionEngineWAMS.class.php

示例11: testFindPkCompositeKey

 public function testFindPkCompositeKey()
 {
     BookstoreDataPopulator::depopulate();
     $c = new ModelCriteria('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', 'Book');
     $books = $c->find();
     foreach ($books as $book) {
         $book->save();
     }
     // retrieve the test data
     $c = new ModelCriteria('bookstore', 'BookListRel');
     $bookListRelTest = $c->findOne();
     $pk = $bookListRelTest->getPrimaryKey();
     $c = new ModelCriteria('bookstore', 'BookListRel');
     $bookListRel = $c->findPk($pk);
     $this->assertEquals($bookListRelTest, $bookListRel, 'findPk() can find objects with composite primary keys');
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:22,代码来源:ModelCriteriaTest.php

示例12: 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();
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:25,代码来源:PropelOnDemandFormatterTest.php

示例13: checkDeletedEntry

 private static function checkDeletedEntry(FileSyncKey $target_key, $wams_asset_id = null, $file_path = null)
 {
     Propel::disableInstancePooling();
     $entry = self::getEntryForKey($target_key);
     Propel::enableInstancePooling();
     if (!is_null($entry) && $entry->getStatus() != entryStatus::DELETED) {
         return false;
     }
     if (!empty($wams_asset_id)) {
         kWAMS::getInstance($target_key->getPartnerId())->deleteAssetById($wams_asset_id);
     }
     if (!empty($file_path)) {
         unlink($file_path);
     }
     return true;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:16,代码来源:kFileSyncUtils.class.php

示例14: initialize

 /**
  * Load Propel config
  * 
  * @param      AgaviDatabaseManager The database manager of this instance.
  * @param      array                An assoc array of initialization params.
  *
  * @author     David Zülke <dz@bitxtender.com>
  * @since      0.10.0
  */
 public function initialize(AgaviDatabaseManager $databaseManager, array $parameters = array())
 {
     parent::initialize($databaseManager, $parameters);
     $configPath = AgaviToolkit::expandDirectives($this->getParameter('config'));
     $datasource = $this->getParameter('datasource', null);
     $use_as_default = $this->getParameter('use_as_default', false);
     $config = (require $configPath);
     if ($datasource === null || $datasource == 'default') {
         if (isset($config['propel']['datasources']['default'])) {
             $datasource = $config['propel']['datasources']['default'];
         } elseif (isset($config['datasources']['default'])) {
             $datasource = $config['datasources']['default'];
         } else {
             throw new AgaviDatabaseException('No datasource given for Propel connection, and no default datasource specified in runtime configuration file.');
         }
     }
     if (!class_exists('Propel')) {
         include 'propel/Propel.php';
     }
     if (!Propel::isInit()) {
         Propel::init($configPath);
     }
     $is13 = version_compare(Propel::VERSION, '1.4', '<');
     // grab the configuration values and inject possibly defined overrides for this data source
     if ($is13) {
         // old-style config array; PropelConfiguration was added after 1.3.0, http://trac.agavi.org/ticket/1195
         $config = Propel::getConfiguration();
         $config['datasources'][$datasource]['adapter'] = $this->getParameter('overrides[adapter]', $config['datasources'][$datasource]['adapter']);
         $config['datasources'][$datasource]['connection'] = array_merge($config['datasources'][$datasource]['connection'], $this->getParameter('overrides[connection]', array()));
         // also the autoload classes
         $config['datasources'][$datasource]['classes'] = array_merge($config['datasources'][$datasource]['classes'], $this->getParameter('overrides[classes]', array()));
         // and init queries
         if (!isset($config['datasources'][$datasource]['connection']['settings']['queries']['query'])) {
             $config['datasources'][$datasource]['connection']['settings']['queries']['query'] = array();
         }
         // array cast because "query" might be a string if just one init query was given, http://trac.agavi.org/ticket/1194
         $config['datasources'][$datasource]['connection']['settings']['queries']['query'] = array_merge((array) $config['datasources'][$datasource]['connection']['settings']['queries']['query'], (array) $this->getParameter('init_queries'));
         // set the new config
         Propel::setConfiguration($config);
     } else {
         $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
         $overrides = (array) $this->getParameter('overrides');
         // set override values
         foreach ($overrides as $key => $value) {
             $config->setParameter($key, $value);
         }
         // handle init queries in a cross-adapter fashion (they all support the "init_queries" param)
         $queries = (array) $config->getParameter('datasources.' . $datasource . '.connection.settings.queries.query', array());
         // yes... it's one array, [connection][settings][queries][query], with all the init queries from the config, so we append to that
         $queries = array_merge($queries, (array) $this->getParameter('init_queries'));
         $config->setParameter('datasources.' . $datasource . '.connection.settings.queries.query', $queries);
     }
     if (true === $this->getParameter('enable_instance_pooling')) {
         Propel::enableInstancePooling();
     } elseif (false === $this->getParameter('enable_instance_pooling')) {
         Propel::disableInstancePooling();
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:67,代码来源:AgaviPropelDatabase.class.php

示例15: 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('DistributionStore', DistributionQuery::create()->findPk($distributionStore->getId()), 'findPk() return right object : DistributionStore');
     $this->assertInstanceOf('DistributionVirtualStore', DistributionQuery::create()->findPk($distributionVirtualStore->getId()), 'findPk() return right object : DistributionVirtualStore');
     Propel::enableInstancePooling();
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:18,代码来源:QueryBuilderInheritanceTest.php


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