/** * @see sfPluginConfiguration */ public function initialize() { sfConfig::set('sf_orm', 'propel'); if (!sfConfig::get('sf_admin_module_web_dir')) { sfConfig::set('sf_admin_module_web_dir', '/sfPropelPlugin'); } sfToolkit::addIncludePath(array(sfConfig::get('sf_root_dir'), sfConfig::get('sf_propel_runtime_path', realpath(dirname(__FILE__) . '/../lib/vendor')))); require_once 'propel/Propel.php'; if (!Propel::isInit()) { if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { Propel::setLogger(new sfPropelLogger($this->dispatcher)); } $propelConfiguration = new PropelConfiguration(); Propel::setConfiguration($propelConfiguration); $this->dispatcher->notify(new sfEvent($propelConfiguration, 'propel.configure')); Propel::initialize(); } $this->dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent')); if (sfConfig::get('sf_web_debug')) { $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelPropel', 'listenToAddPanelEvent')); } if (sfConfig::get('sf_test')) { $this->dispatcher->connect('context.load_factories', array($this, 'clearAllInstancePools')); } }
protected function tearDown() { if ($this->oldPropelConfiguration) { Propel::setConfiguration($this->oldPropelConfiguration); Propel::initialize(); } parent::tearDown(); }
protected function setUp() { parent::setUp(); $xmlDom = new DOMDocument(); $xmlDom->load(dirname(__FILE__) . '/../../../../fixtures/reverse/mysql/runtime-conf.xml'); $xml = simplexml_load_string($xmlDom->saveXML()); $phpconf = OpenedPropelConvertConfTask::simpleXmlToArray($xml); Propel::setConfiguration($phpconf); Propel::initialize(); }
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() { $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(); }
protected function setUp() { $this->markTestSkipped('PGSQL unit test'); parent::setUp(); $xmlDom = new DOMDocument(); $xmlDom->load(dirname(__FILE__) . '/../../../../fixtures/reverse/pgsql/runtime-conf.xml'); $xml = simplexml_load_string($xmlDom->saveXML()); $phpconf = TestablePropelConvertConfTask::simpleXmlToArray($xml); Propel::setConfiguration($phpconf); Propel::initialize(); $this->con = Propel::getConnection('reverse-bookstore'); $this->con->beginTransaction(); }
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(); }
public static function initialize() { $dbConfigs = array(); $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaDatabaseConfig'); foreach ($pluginInstances as $pluginInstance) { $dbConfigs[] = $pluginInstance->getDatabaseConfig(); } foreach ($dbConfigs as $dbConfig) { self::addExtraConfiguration($dbConfig); } Propel::setConfiguration(self::$config); Propel::setLogger(KalturaLog::getInstance()); Propel::initialize(); }
/** * {@inheritdoc} */ public function boot() { require_once $this->container->getParameter('propel.path') . '/runtime/lib/Propel.php'; if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) { set_include_path($this->container->getParameter('propel.phing_path') . '/classes' . PATH_SEPARATOR . get_include_path()); } if (!\Propel::isInit()) { \Propel::setConfiguration($this->container->get('propel.configuration')); if ($this->container->getParameter('propel.logging')) { $this->container->get('propel.configuration')->setParameter('debugpdo.logging.details', array('time' => array('enabled' => true), 'mem' => array('enabled' => true))); \Propel::setLogger($this->container->get('propel.logger')); } \Propel::initialize(); } }
public static function initialize() { $dbConfigs = self::getExtraDatabaseConfigs(); foreach ($dbConfigs as $dbConfig) { self::addExtraConfiguration($dbConfig); } Propel::setConfiguration(self::$config); Propel::setLogger(KalturaLog::getInstance()); try { Propel::initialize(); } catch (PropelException $pex) { KalturaLog::alert($pex->getMessage()); throw new PropelException("Database error"); } }
/** * @static * @param string $connectionName * @return PropelPDO */ public static function instanciate($connectionName) { $propelConfiguration = Propel::getConfiguration(); if (isset($propelConfiguration['datasources'][$connectionName]['connection'])) { $parameters = $propelConfiguration['datasources'][$connectionName]['connection']; } else { if (isset($propelConfiguration['datasources'][Propel::getDefaultDB()])) { $propelConfiguration['datasources'][$connectionName] = $propelConfiguration['datasources'][Propel::getDefaultDB()]; Propel::setConfiguration(new PropelConfiguration($propelConfiguration)); $parameters = $propelConfiguration['datasources'][$connectionName]['connection']; } else { throw new Exception(sprintf("Unable to find connection parameters for connection '%s'", $connectionName)); } } return Propel::initConnection($parameters, $connectionName); }
/** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { $this->writeSection($output, '[Propel] You are running the command: propel:database:create'); list($name, $config) = $this->getConnection($input, $output); $dbName = $this->parseDbName($config['connection']['dsn']); $query = 'CREATE DATABASE ' . $dbName . ';'; try { \Propel::setConfiguration($this->getTemporaryConfiguration($name, $config)); $connection = \Propel::getConnection($name); $statement = $connection->prepare($query); $statement->execute(); $output->writeln(sprintf('<info>Database <comment>%s</comment> has been created.</info>', $dbName)); } catch (\Exception $e) { $this->writeSection($output, array('[Propel] Exception catched', '', $e->getMessage()), 'fg=white;bg=red'); } }
/** * {@inheritdoc} */ public function boot() { require_once $this->container->getParameter('propel.path') . '/runtime/lib/Propel.php'; if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) { set_include_path($this->container->getParameter('kernel.root_dir') . '/..' . PATH_SEPARATOR . $this->container->getParameter('propel.phing_path') . PATH_SEPARATOR . $this->container->getParameter('propel.phing_path') . '/classes' . PATH_SEPARATOR . get_include_path()); } if (!\Propel::isInit()) { \Propel::setConfiguration($this->container->get('propel.configuration')); if ($this->container->getParameter('propel.logging')) { $config = $this->container->get('propel.configuration'); $config->setParameter('debugpdo.logging.methods', array('PropelPDO::exec', 'PropelPDO::query', 'PropelPDO::prepare', 'DebugPDOStatement::execute'), false); $config->setParameter('debugpdo.logging.details', array('time' => array('enabled' => true), 'mem' => array('enabled' => true), 'connection' => array('enabled' => true))); \Propel::setLogger($this->container->get('propel.logger')); } \Propel::initialize(); } }
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(); }
/** * {@inheritdoc} */ public function boot() { trigger_error("The PropelBundle uses a new branching model, you should switch to the 1.1 branch (1.1.x versions). For more information, please read: https://github.com/propelorm/PropelBundle/wiki", E_USER_DEPRECATED); require_once $this->container->getParameter('propel.path') . '/runtime/lib/Propel.php'; if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) { set_include_path($this->container->getParameter('kernel.root_dir') . '/..' . PATH_SEPARATOR . $this->container->getParameter('propel.phing_path') . PATH_SEPARATOR . $this->container->getParameter('propel.phing_path') . '/classes' . PATH_SEPARATOR . get_include_path()); } if (!\Propel::isInit()) { \Propel::setConfiguration($this->container->get('propel.configuration')); if ($this->container->getParameter('propel.logging')) { $config = $this->container->get('propel.configuration'); $config->setParameter('debugpdo.logging.methods', array('PropelPDO::exec', 'PropelPDO::query', 'PropelPDO::prepare', 'DebugPDOStatement::execute'), false); $config->setParameter('debugpdo.logging.details', array('time' => array('enabled' => true), 'mem' => array('enabled' => true), 'connection' => array('enabled' => true))); \Propel::setLogger($this->container->get('propel.logger')); } \Propel::initialize(); } }
/** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { list($name, $config) = $this->getConnection($input, $output); $dbName = $this->parseDbName($config['connection']['dsn']); if (null === $dbName) { return $output->writeln('<error>No database name found.</error>'); } else { $query = 'CREATE DATABASE ' . $dbName . ';'; } try { \Propel::setConfiguration($this->getTemporaryConfiguration($name, $config)); $connection = \Propel::getConnection($name); $statement = $connection->prepare($query); $statement->execute(); $output->writeln(sprintf('<info>Database <comment>%s</comment> has been created.</info>', $dbName)); } catch (\Exception $e) { $this->writeSection($output, array('[Propel] Exception caught', '', $e->getMessage()), 'fg=white;bg=red'); } }
public function build($dsn = null, $user = null, $pass = null, $adapter = null) { if (null === $dsn) { $dsn = 'sqlite::memory:'; } if (null === $adapter) { $adapter = new DBSQLite(); } $con = new PropelPDO($dsn, $user, $pass); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $this->buildSQL($con); $this->buildClasses(); $name = $this->getDatabase()->getName(); if (!Propel::isInit()) { Propel::setConfiguration(array()); } Propel::setDB($name, $adapter); Propel::setConnection($name, $con, Propel::CONNECTION_READ); Propel::setConnection($name, $con, Propel::CONNECTION_WRITE); return $con; }
/** * 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(); } }
/** * Initialize sfymfony propel * * @param sfEventDispatcher $dispatcher * @param string $culture */ public static function initialize(sfEventDispatcher $dispatcher, $culture = null) { if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { // add propel logger Propel::setLogger(new sfPropelLogger($dispatcher)); } // propel initialization $configuration = sfPropelDatabase::getConfiguration(); if ($configuration) { Propel::setConfiguration($configuration); if (!Propel::isInit()) { Propel::initialize(); } } $dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent')); if (!is_null($culture)) { self::setDefaultCulture($culture); } else { if (class_exists('sfContext', false) && sfContext::hasInstance() && ($user = sfContext::getInstance()->getUser())) { self::setDefaultCulture($user->getCulture()); } } self::$initialized = true; }
/** * @return \PropelPDO */ protected function getMockPropelConnection() { if (!class_exists('Lexik\\Bundle\\TranslationBundle\\Propel\\om\\BaseFile')) { // classes are built in-memory. $builder = new \PropelQuickBuilder(); $builder->setSchema(file_get_contents(__DIR__ . '/../../Resources/config/propel/schema.xml')); $builder->setClassTargets(array('tablemap', 'peer', 'object', 'query')); $con = $builder->build(); } else { // in memory-classes already exist, create connection and SQL manually $dsn = 'sqlite::memory:'; $adapter = new \DBSQLite(); $con = new \PropelPDO($dsn, null, null); $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING); $name = 'default'; if (!\Propel::isInit()) { \Propel::setConfiguration(array('datasources' => array('default' => $name))); } \Propel::setDB($name, $adapter); \Propel::setConnection($name, $con, \Propel::CONNECTION_READ); \Propel::setConnection($name, $con, \Propel::CONNECTION_WRITE); // don't rebuild classes $builder = new \PropelQuickBuilder(); $builder->setSchema(file_get_contents(__DIR__ . '/../../Resources/config/propel/schema.xml')); $builder->buildSQL($con); } return $con; }
* (c) 2007 Rob Rosenbaum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* * The contents of this file came mostly from the following page: * http://www.symfony-project.com/snippets/snippet/215 */ if (!@constant('SF_APP')) { die('Constant "SF_APP" must be defined in your test script.' . "\n"); } if (!@constant('SF_ENVIRONMENT')) { // Only load constants in not done before (group tests) define('SF_ENVIRONMENT', 'test'); define('SF_DEBUG', TRUE); define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../..')); $_test_dir = SF_ROOT_DIR . '/test'; // symfony directories include SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; require_once $sf_symfony_lib_dir . '/vendor/lime/lime.php'; require_once $sf_symfony_lib_dir . '/util/sfCore.class.php'; require_once dirname(__FILE__) . '/../lib/sfPropelTest.php'; sfCore::initSimpleAutoload(array(SF_ROOT_DIR . '/lib/model', $sf_symfony_lib_dir, SF_ROOT_DIR . '/lib', SF_ROOT_DIR . '/apps/theApp/lib', SF_ROOT_DIR . '/plugins')); // Location plugins set_include_path($sf_symfony_lib_dir . '/vendor' . PATH_SEPARATOR . SF_ROOT_DIR . PATH_SEPARATOR . get_include_path()); sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); sfContext::getInstance(); Propel::setConfiguration(sfPropelDatabase::getConfiguration()); Propel::initialize(); }
private static function enableSlaveConf($dbName) { $configuration = Propel::getConfiguration(); if (!isset($configuration['datasources'][$dbName]['slaves']['connection'])) { $configuration['datasources'][$dbName]['slaves']['connection'] = self::$_slaveConfig[$dbName]; Propel::setConfiguration($configuration); Propel::initialize(); } Propel::setForceMasterConnection(false); }
public function __construct($config) { Propel::setConfiguration($config); Propel::initialize(); $this->loadProcesses(); }
<?php error_reporting(E_ALL); require_once 'bootstrap.php'; $config = Ezer_Config::createFromPath('config.xml'); Propel::setConfiguration($config->database->toArray()); Propel::initialize(); // insert process $variable1 = new Ezer_Variable(); $variable1->setName('title'); $variable1->setType('string'); $variable2 = new Ezer_Variable(); $variable2->setName('counter'); $partTitle = new Ezer_Variable(); $partTitle->setName('title'); $partTitle->setType('string'); $variable2->parts[] = $partTitle; $partCounts = new Ezer_Variable(); $partCounts->setName('counts'); $partCounts->setType('array'); $variable2->parts[] = $partCounts; $partArray = new Ezer_Variable(); $partCounts->parts[] = $partArray; $partStart = new Ezer_Variable(); $partStart->setName('start'); $partStart->setType('int'); $partArray->parts[] = $partStart; $partStop = new Ezer_Variable(); $partStop->setName('stop'); $partStop->setType('int'); $partArray->parts[] = $partStop;
/** * @return \Igorw\Silex\Config */ function getAppConfig($key = null) { static $cnf = null; if (is_null($cnf)) { $cnf = new Igorw\Silex\Config(getAppEnv()); } if (!is_null($key)) { return $cnf->getConfig($key); } return $cnf; } // Include the main Propel script require_once __DIR__ . '/vendor/propel/runtime/lib/Propel.php'; // Initialize Propel with the runtime configuration $propelcnf = (array) getAppConfig('propel'); $propelcnf['classmap'] = (include __DIR__ . '/config/classmap-gw2spidy-conf.php'); Propel::setConfiguration($propelcnf); Propel::initialize(); // initiate the application, check config to enable debug / sql logging when needed $app = new Silex\Application(); // register config provider $app->register(new Igorw\Silex\ConfigServiceProvider(getAppConfig())); $app->register(new TMG\Services\ServicesProvider()); $app->register(new Rafal\MemcacheServiceProvider\MemcacheServiceProvider()); // setup dev mode related stuff based on config isset($app['sql_logging']) && $app['sql_logging'] && $app->enableSQLLogging(); // register providers $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
public function __construct($config) { Propel::setConfiguration($config); Propel::initialize(); }
<?php $conf_path = realpath(dirname(__FILE__) . '/fixtures/bookstore/build/conf/bookstore-conf.php'); if (!file_exists($conf_path)) { throw new Exception('Bookstore project must be built'); } // Add build/classes/ and classes/ to path set_include_path(realpath(dirname(__FILE__) . '/fixtures/bookstore/build/classes') . PATH_SEPARATOR . dirname(__FILE__) . '/../runtime/classes' . PATH_SEPARATOR . get_include_path()); require_once 'propel/Propel.php'; $conf = (include $conf_path); $conf['log'] = null; Propel::setConfiguration($conf); Propel::initialize(); include_once 'tools/helpers/bookstore/validator/ISBNValidator.php'; class PropelSpeedTest { public $iterations; public function __construct($iterations = 100) { $this->iterations = $iterations; } public function run() { $timers = array(); fwrite(STDOUT, "Running scenario"); // perform tests for ($i = 0; $i < $this->iterations; $i++) { fwrite(STDOUT, '.'); $this->setUp(); $t = microtime(true); $this->testSpeed();
/** * 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(); } }