protected function setUp() { parent::setUp(); BookstoreDataPopulator::populate($this->con); Propel::disableInstancePooling(); $this->books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); }
protected function setUp() { if (!class_exists('DBStudent')) { $schema = <<<XML <database name="class_prefixed_db"> <table name="student"> <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" /> <column name="name" type="VARCHAR" required="true" /> </table> <table name="classmate"> <behavior name="equal_nest"> <parameter name="parent_table" value="student" /> </behavior> </table> </database> XML; $builder = $this->getBuilder($schema); $config = $builder->getConfig(); $config->setBuildProperty('classPrefix', 'DB'); $builder->setConfig($config); $builder->build(); } Propel::disableInstancePooling(); DBStudentQuery::create()->deleteAll(); }
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(); }
public function setUp() { parent::setUp(); if (!interface_exists('Sensio\\Bundle\\FrameworkExtraBundle\\Request\\ParamConverter\\ParamConverterInterface')) { $this->markTestSkipped('SensioFrameworkExtraBundle is not available.'); } \Propel::disableInstancePooling(); }
public function __construct() { $this->wwwPath = Curry_Core::$config->curry->wwwPath; Propel::disableInstancePooling(); Propel::setLogger(null); if ($this->debug) { $this->con = Propel::getConnection(PagePeer::DATABASE_NAME); $this->con->useDebug(true); } $this->setupLogger(); }
public function __construct($label = false) { // Different package name to test 2 parent::__construct('test_version', $label); // Clear out old table map, create us a new one $this->resetDatabaseMap(BaseTestVersionTestOrganiserPeer::DATABASE_NAME, array('TestVersionTestOrganiserTableMap', 'TestVersionTestEventTableMap', 'TestVersionKnownNodeTableMap')); $this->node = $this->createKnownNode(new TestVersionKnownNode(), $this->conNode); // I've witnessed incorrect caching on 27 Nov 2011, might be due to my messing about // with Propel internals too much. Disabling pooling for tests :-0 Propel::disableInstancePooling(); }
function initialize() { set_include_path(realpath(dirname(__FILE__) . '/build/classes') . PATH_SEPARATOR . get_include_path()); require_once "vendor/autoload.php"; $conf = (include realpath(dirname(__FILE__) . '/build/conf/bookstore-conf.php')); $conf['log'] = null; Propel::setConfiguration($conf); Propel::initialize(); Propel::disableInstancePooling(); $this->con = Propel::getConnection('bookstore'); $this->initTables(); }
function initialize() { set_include_path(realpath(dirname(__FILE__) . '/build/classes') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../propel_17/vendor/propel/runtime/lib') . PATH_SEPARATOR . get_include_path()); require_once 'Propel.php'; $conf = (include realpath(dirname(__FILE__) . '/build/conf/bookstore-conf.php')); $conf['log'] = null; Propel::setConfiguration($conf); Propel::initialize(); Propel::disableInstancePooling(); $this->con = Propel::getConnection('bookstore'); $this->con->setAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES, true); $this->initTables(); }
function initialize() { $loader = (require_once __DIR__ . '/../propel_16/vendor/autoload.php'); set_include_path(__DIR__ . '/build/classes'); $conf = (include realpath(dirname(__FILE__) . '/build/conf/bookstore-conf.php')); $conf['log'] = null; Propel::setConfiguration($conf); Propel::initialize(); Propel::disableInstancePooling(); $this->con = Propel::getConnection('bookstore'); $this->con->setAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES, true); $this->initTables(); }
public function postUp($manager) { // add the post-migration code here require_once $_SERVER['PWD'] . '/base/lib/inc.php'; $oConnection = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); Propel::disableInstancePooling(); $stmt = DocumentPeer::doSelectStmt(DocumentQuery::create()->clearSelectColumns()->addSelectColumn('documents.id')->addSelectColumn('documents.hash')); foreach ($stmt->fetchAll(PDO::FETCH_NUM) as $row) { $iId = $row[0]; $sHash = $row[1]; $oConnection->exec('INSERT IGNORE INTO `document_data` (`hash`, `data`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES ("' . $sHash . '", (SELECT `data` FROM `documents` WHERE `id` = ' . $iId . '), (SELECT `created_at` FROM `documents` WHERE `id` = ' . $iId . '), (SELECT `updated_at` FROM `documents` WHERE `id` = ' . $iId . '), (SELECT `created_by` FROM `documents` WHERE `id` = ' . $iId . '), (SELECT `updated_by` FROM `documents` WHERE `id` = ' . $iId . '))'); } $stmt->closeCursor(); }
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(); }
/** * Constructor. */ public function __construct() { parent::__construct(); // Override and increase max execution time if set $timeLimit = ini_get('max_execution_time'); if ($timeLimit && $timeLimit < 250) { @set_time_limit(250); } Propel::disableInstancePooling(); Propel::setLogger(null); // make sure all classes are included foreach (Curry_Propel::getModels() as $classes) { foreach ($classes as $clazz) { class_exists($clazz . 'Peer', true); } } }
function initialize() { set_include_path(realpath(dirname(__FILE__) . '/build/classes') . PATH_SEPARATOR . get_include_path()); if (file_exists("propel_16/vendor/autoload.php")) { require_once "propel_16/vendor/autoload.php"; } else { require_once "../propel_16/vendor/autoload.php"; } $conf = (include realpath(dirname(__FILE__) . '/build/conf/bookstore-conf.php')); $conf['log'] = null; Propel::setConfiguration($conf); Propel::initialize(); Propel::disableInstancePooling(); $this->con = Propel::getConnection('bookstore'); $this->con->setAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES, true); $this->initTables(); }
/** * 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)); }
/** * 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(); } }
/** * 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; }
protected function setUp() { if (!class_exists('Person')) { $schema = <<<XML <database name="equal_nest_behavior"> <table name="person"> <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" /> <column name="name" type="VARCHAR" required="true" /> </table> <table name="friend"> <behavior name="equal_nest"> <parameter name="parent_table" value="person" /> </behavior> </table> </database> XML; $this->getBuilder($schema)->build(); } Propel::disableInstancePooling(); PersonQuery::create()->deleteAll(); }
public function setUp() { if (!extension_loaded('memcached')) { $this->markTestSkipped("Memcached extension is not loaded"); } Domino\CacheStore\Factory::setOption(array('storage' => 'memcached', 'prefix' => 'datacache_test', 'default_ttl' => 360, 'servers' => array(array('localhost', 11211, 20)))); if (!class_exists("DataCacheBehaviorMemcachedTest")) { $schema = <<<EOF <database name="data_cache_behavior_memcached_test" defaultIdMethod="native"> <table name="data_cache_behavior_memcached_test"> <column name="id" required="true" primaryKey="true" type="INTEGER" /> <column name="name" type="VARCHAR" required="true" /> <behavior name="data_cache"> <parameter name="backend" value="memcached" /> </behavior> </table> </database> EOF; $this->getBuilder($schema)->build(); } DataCacheBehaviorMemcachedTestPeer::doDeleteAll(); Propel::disableInstancePooling(); }
/** * 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); }
/** * 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(); } }
protected function setUp() { if (!class_exists('User')) { $schema = <<<XML <database name="equal_nest_behavior_with_custom_parameters"> <table name="user"> <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" /> <column name="name" type="VARCHAR" required="true" /> </table> <table name="ami"> <behavior name="equal_nest"> <parameter name="parent_table" value="user" /> <parameter name="reference_column_1" value="ami_1" /> <parameter name="reference_column_2" value="ami_2" /> </behavior> </table> </database> XML; $this->getBuilder($schema)->build(); } Propel::disableInstancePooling(); UserQuery::create()->deleteAll(); }
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(); }
public function testFindOneWithoutUsingInstancePool() { BookstoreDataPopulator::populate(); Propel::disableInstancePooling(); $c = new ModelCriteria('bookstore', 'Book'); $c->orderBy('Book.Title'); $c->join('Book.Author'); $c->with('Author'); $c->join('Book.Publisher'); $c->with('Publisher'); $this->assertCorrectHydration1($c, 'without instance pool'); Propel::enableInstancePooling(); }
/** * @param PropelFormatter $formatter * @param PDOStatement $stmt */ public function __construct(PropelFormatter $formatter, PDOStatement $stmt) { $this->formatter = $formatter; $this->stmt = $stmt; $this->enableInstancePoolingOnFinish = Propel::disableInstancePooling(); }
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(); }
/** * Load Propel config * * @param AgaviDatabaseManager The database manager of this instance. * @param array An assoc array of initialization params. * * @author David Zülke <*****@*****.**> * @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(); } }
public function testDoSelectJoinOneToOne() { $con = Propel::getConnection(); $count = $con->getQueryCount(); Propel::disableInstancePooling(); $c = new Criteria(); $accs = BookstoreEmployeeAccountPeer::doSelectJoinBookstoreEmployee($c); Propel::enableInstancePooling(); $this->assertEquals(1, $con->getQueryCount() - $count, 'doSelectJoin() makes only one query in a one-to-one relationship'); }
public function testEquals() { Propel::disableInstancePooling(); $eleve1 = EleveQuery::create()->findOneByLogin('Florence Michu'); usleep(1); $eleve1idem = EleveQuery::create()->findOneByLogin('Florence Michu'); $this->assertEquals($eleve1, $eleve1idem); Propel::enableInstancePooling(); }
// Remove time limit if ($webcall) { if (pcntl_fork()) { // Fork process exit(42); // This marks a successful fork, so we should return success to the caller } posix_setsid(); // Make child process session leader } // Okay, we're now in our own execution space. Let's begin // We need to restart Propel to regain access to the DB Propel::init(LILAC_FS_ROOT . "includes/lilac-conf.php"); // disable instance pooling. Should reduce memory footprint required for this // job. Propel::disableInstancePooling(); // Load engines ImportEngine::getAvailableEngines(); if (isset($argv[1]) && is_numeric($argv[1])) { $importJob = ImportJobPeer::retrieveByPK($argv[1]); if (!$importJob) { print "Job with id: " . $argv[1] . " not found.\n"; exit(20); } $importJob->setStartTime(time()); $importJob->clearLog(); $importJob->save(); // Okay, let's get the ImportConfig $config = $importJob->getConfig(); $config = unserialize($config); $engineClass = $config->getEngineClass();
/** * To illustrate that instance pooling makes no difference */ public function testPoisonedCacheWithJoinInstancePoolingDisabled() { Propel::disableInstancePooling(); $this->testPoisonedCacheWhenDoSelectJoinAuthor(); }