本文整理汇总了PHP中sfDatabaseManager类的典型用法代码示例。如果您正苦于以下问题:PHP sfDatabaseManager类的具体用法?PHP sfDatabaseManager怎么用?PHP sfDatabaseManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfDatabaseManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$visiteurs_dir = sfConfig::get('sf_root_dir') . '/web/visiteur/';
$interactifs_dir = sfConfig::get('sf_root_dir') . '/web/interactif';
$finder = new sfFinder();
$fileSystem = new sfFilesystem();
foreach ($finder->in($visiteurs_dir) as $file) {
//echo 'search in '. $file;
if (is_file($file) && basename($file) != '.DS_Store') {
$realpath = str_replace($visiteurs_dir, "", $file);
$split = explode('/', $realpath);
if (count($split) > 2) {
//print_r($split);
//exit;
$visiteur_id = $split[0];
$interactif_id = $split[1];
$filename = basename($file);
// check if symlink exist
if (Doctrine::getTable('Interactif')->symlinkDocument($interactif_id, $visiteur_id, $filename, $file)) {
$this->logSection("INFO", "Symlink " . $interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id . '/' . $filename);
}
}
}
}
$this->logSection("INFO", "END Symlink interactif directory");
}
示例2: execute
protected function execute($arguments = array(), $options = array())
{
$app = $options['app'];
$env = $options['env'];
$this->bootstrapSymfony($app, $env, true);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase('doctrine')->getConnection();
$this->logSection('import', 'initializing...');
$plugins = SymfonyPluginApi::getPlugins();
$count = 0;
foreach ($plugins as $plugin) {
$new = Doctrine::getTable('SymfonyPlugin')->findOneByTitle($plugin['id']);
// if plugin exists update info. Otherwise, create it
if ($new) {
// Nothing Yet
} elseif ($plugin['id']) {
$new = new SymfonyPlugin();
$new['title'] = (string) $plugin['id'];
$new['description'] = (string) $plugin->description;
$new['repository'] = (string) $plugin->scm;
$new['image'] = (string) $plugin->image;
$new['homepage'] = (string) $plugin->homepage;
$new['ticketing'] = (string) $plugin->ticketing;
$new->saveNoIndex();
$this->logSection('import', "added '{$new->title}'");
$count++;
}
}
$this->logSection('import', "Running Lucene Cleanup");
$this->runLuceneRebuild();
$this->logSection('import', "Completed. Added {$count} new plugins(s)");
}
示例3: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$this->logSection('Create directory', "Visiteur");
$q = Doctrine_Query::create()->from('Visiteur v');
$visiteurs = $q->execute();
foreach ($visiteurs as $visiteur) {
$visiteur->createDataFolder();
}
$this->logSection('Create directory', "Interactif");
$q = Doctrine_Query::create()->from('Interactif i');
$interactifs = $q->execute();
foreach ($interactifs as $interactif) {
$interactif->createDataFolder();
}
$this->logSection('Create directory', "Exposition");
$q = Doctrine_Query::create()->from('Exposition v');
$expositions = $q->execute();
foreach ($expositions as $exposition) {
$exposition->createDataFolder();
}
$this->logSection('Create directory', "Medaille");
$fileSystem = new sfFilesystem();
$fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille");
$this->logSection('Create directory', "MedailleType");
$fileSystem = new sfFilesystem();
$fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille_type");
}
示例4: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$table = Doctrine::getTable('sfGuardUser');
$users = $table->createQuery('u')->innerJoin('u.Profile p')->execute();
$first = true;
foreach ($users as $user) {
if (preg_match("/[^\\w]/", $user->username)) {
$user->username = preg_replace("/[^\\w]/", "_", $user->username);
while ($table->findOneByUsername($user->username)) {
$user->username .= rand(0, 9);
echo $user->username;
}
$user->save();
$profile->save();
if ($first) {
echo "The following usernames required change, contact them if they are legitimate users and\nlet them know their new username.\n";
echo "The report below shows the NEW username only.\n\n";
$first = false;
}
echo "Username: " . $user->username . ' Fullname: ' . $user->Profile->fullname . ' Email: ' . $user->getEmailAddress() . "\n";
}
$profile = $user->getProfile();
if (preg_match("/[\\<\\>\\&\\|]/", $profile->fullname)) {
// No need for a big announcement because we don't log in by our full names
$profile->fullname = preg_replace("/[\\<\\>\\&\\|]/", "_", $profile->fullname);
$profile->save();
}
}
}
示例5: execute
protected function execute($arguments = array(), $options = array())
{
if (!$this->safeToRun()) {
print "Process already running!\n";
die;
}
$timer = sfTimerManager::getTimer('execute');
$databaseManager = new sfDatabaseManager($this->configuration);
$databaseManager->initialize($this->configuration);
//set up index
$index = EntityTable::getLuceneIndex();
//delete deleted entities
$q = LsDoctrineQuery::create()->from('Entity e')->where('e.is_deleted = ?', true)->setHydrationMode(Doctrine::HYDRATE_ARRAY);
foreach ($q->execute() as $entity) {
if ($hits = $index->find('key:' . $entity['id'])) {
if ($options['debug_mode']) {
printf("Deleting index for Entity %s\n", $entity['id']);
}
foreach ($hits as $hit) {
$index->delete($hit->id);
}
}
}
printf("Memory used: %s\n", LsNumber::makeBytesReadable(memory_get_usage()));
printf("Index size: %s\n", $index->count());
$timer->addTime();
printf("Run time: %s\n", $timer->getElapsedTime());
sfTimerManager::clearTimers();
}
示例6: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
}
示例7: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
parent::execute($arguments, $options);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$options_task_server_backup = array('location' => $arguments['location'], 'filepath' => $arguments['filepath']);
if ($arguments['snapshot']) {
$options_task_server_backup['snapshot'] = $arguments['snapshot'];
}
if ($arguments['newsnapshot']) {
$options_task_server_backup['newsnapshot'] = $arguments['newsnapshot'];
}
if ($arguments['delete']) {
$options_task_server_backup['deletesnapshot'] = $arguments['delete'];
}
if ($arguments['location']) {
if ($arguments['do_not_generate_tar'] && $arguments['do_not_generate_tar'] != 'false') {
$options_task_server_backup['do_not_generate_tar'] = true;
}
}
$task_server_backup = new serverBackupTask($this->dispatcher, new sfFormatter());
return $task_server_backup->run(array('serverid' => $arguments['serverid']), $options_task_server_backup);
}
示例8: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
/*
if($options['include'] != "" && $options['exclude'] != "")
{
throw new Exception("Only one option is authorized");
}
*/
if ($options['include'] != "") {
$to_replace = split(",", $options['include']);
sfConfig::set('app_sync_tables', $to_replace);
}
if ($options['exclude'] != "") {
$tables = sfConfig::get('app_sync_tables');
$excludes = split(",", $options['exclude']);
foreach ($excludes as $exclude) {
if (($key = array_search($exclude, $tables)) !== false) {
unset($tables[$key]);
}
}
sfConfig::set('app_sync_tables', $tables);
}
$sync = new ServerVipSync($this->configuration);
$sync->startSync();
}
示例9: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$MODEL_CLASS_NAME = $arguments['classname'];
if ('doctrine' === sfConfig::get('sf_orm')) {
$table = Doctrine_Core::getTable($MODEL_CLASS_NAME);
$fieldNames = $table->getColumnNames();
$this->log(sprintf('%s', $MODEL_CLASS_NAME));
$this->log(sprintf(' %s_data', $MODEL_CLASS_NAME));
foreach ($fieldNames as $fieldName) {
$this->log(sprintf(' %-20s %s', $fieldName . ':', $table->getTypeOf($fieldName)));
}
} else {
$MODEL_CLASS_NAME_PEER = $MODEL_CLASS_NAME . 'Peer';
$peerClass = new $MODEL_CLASS_NAME_PEER();
$fieldNames = $peer_class->getFieldNames(BasePeer::TYPE_FIELDNAME);
$this->log(sprintf('%s', $MODEL_CLASS_NAME));
$this->log(sprintf(' %s_data', $MODEL_CLASS_NAME));
foreach ($fieldNames as $fieldName) {
$this->log(sprintf(' %-20s', $fieldName . ':'));
}
}
}
开发者ID:hidenorigoto,项目名称:xnGenerateFixtureTemplateTask,代码行数:25,代码来源:xnGenerateFixtureTemplateTask.class.php
示例10: execute
protected function execute($arguments = array(), $options = array()) {
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$context = sfContext::createInstance($this->configuration);
sfProjectConfiguration::getActive()->loadHelpers('Partial', 'I18N', 'Url');
$serverUrl = $options['setenvironment'] == '' ? $serverUrl = $options['host'] : $serverUrl = $options['host'] . '/' . $options['setenvironment'];
$workflows = WorkflowVersionTable::instance()->getWorkflowsToStart(time())->toArray();
foreach($workflows as $workflow) {
$sender = WorkflowTemplateTable::instance()->getWorkflowTemplateById($workflow['workflowtemplate_id'])->toArray();
$userSettings = new UserMailSettings($sender[0]['sender_id']);
$sendMail = new SendStartWorkflowEmail($userSettings, $context, $workflow, $sender, $serverUrl);
$workflowTemplate = WorkflowTemplateTable::instance()->getWorkflowTemplateByVersionId($workflow['id']);
WorkflowVersionTable::instance()->startWorkflowInFuture($workflow['id']);
$sendToAllSlotsAtOnce = $workflowTemplate[0]->getMailinglistVersion()->toArray();
if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) {
$calc = new CreateWorkflow($workflow['id']);
$calc->setServerUrl($serverUrl);
$calc->setContext($context);
$calc->addAllSlots();
}
else {
$calc = new CreateWorkflow($workflow['id']);
$calc->setServerUrl($serverUrl);
$calc->setContext($context);
$calc->addSingleSlot();
}
}
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();
$sql = 'SELECT id FROM community';
$where = array();
if ( $options['cmin'] && $options['cmax'] && $options['cmin'] <= $options['cmax'])
{
$sql .= ' WHERE id BETWEEN ? AND ?';
$where = array(intval($options['cmin']),intval($options['cmax']));
}
$commuIds = $this->conn->fetchColumn($sql, $where);
foreach ($commuIds as $cid)
{
for ($i=0; $i < $options['number']; ++$i)
{
$ct = new CommunityTopic();
$ct->setCommunity(Doctrine::getTable('community')->find($cid));
$ct->setMemberId(self::fetchRandomMemberId($cid));
$ct->setName('name');
$ct->setBody('body');
$ct->save();
$ct->free();
$this->logSection('created a community topic', sprintf("%s", $cid));
}
}
}
示例12: execute
/**
* DOCUMENT ME
* @param mixed $arguments
* @param mixed $options
*/
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
// PDO connection not so useful, get the doctrine one
$conn = Doctrine_Manager::connection();
if ($options['table'] === 'aPage') {
$q = Doctrine::getTable('aLuceneUpdate')->createQuery('u');
} else {
$q = Doctrine::getTable($options['table'])->createQuery('o')->where('o.lucene_dirty IS TRUE');
}
if ($options['limit'] !== false) {
$q->limit($options['limit'] + 0);
}
$updates = $q->execute();
$i = 0;
foreach ($updates as $update) {
$i++;
if ($options['table'] === 'aPage') {
$page = aPageTable::retrieveByIdWithSlots($update->page_id, $update->culture);
// Careful, pages die
if ($page) {
$page->updateLuceneIndex();
}
$update->delete();
} else {
// The actual object
$update->updateLuceneIndex();
$update->lucene_dirty = false;
$update->save();
}
}
}
示例13: execute
protected function execute($arguments = array(), $options = array())
{
$configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->initialize($configuration);
$this->db = Doctrine_Manager::connection();
if ($options['house_senate'] == 'house') {
$sql = 'select e1.id,e2.id from entity e1 left join political_candidate pc on pc.entity_id = e1.id left join political_candidate pc2 on pc2.house_fec_id = pc.house_fec_id left join entity e2 on e2.id = pc2.entity_id where e1.is_deleted = 0 and e2.is_deleted = 0 and e1.id <> e2.id and pc.id is not null and pc2.id is not null and pc.id <> pc2.id and pc.house_fec_id is not null and pc.house_fec_id <> "" and e1.id < e2.id group by e1.id,e2.id';
} else {
if ($options['house_senate'] == 'senate') {
$sql = 'select e1.id,e2.id from entity e1 left join political_candidate pc on pc.entity_id = e1.id left join political_candidate pc2 on pc2.senate_fec_id = pc.senate_fec_id left join entity e2 on e2.id = pc2.entity_id where e1.is_deleted = 0 and e2.is_deleted = 0 and e1.id <> e2.id and pc.id is not null and pc2.id is not null and pc.id <> pc2.id and pc.senate_fec_id is not null and pc.senate_fec_id <> "" and e1.id < e2.id group by e1.id,e2.id';
} else {
echo 'House or Senate not selected...ending script' . "\n";
die;
}
}
$stmt = $this->db->execute($sql);
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
$e1 = Doctrine::getTable('Entity')->find($row[0]);
$e2 = Doctrine::getTable('Entity')->find($row[1]);
$mergedEntity = EntityTable::mergeAll($e1, $e2);
$e2->setMerge(true);
$e2->clearRelated();
$e2->delete();
echo ' Successfully merged ' . $e2->name . "\n";
if ($options['test_mode']) {
die;
}
}
}
示例14: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();
$communityIds = $this->getCommunityIds();
for ($i=0; $i < $options['communitynumber']; ++$i)
{
$communityId = $this->fetchRandomCommunityId($communityIds);
$topicIds = $this->getTopicIds($communityId);
$memberIds = $this->getMemberIds($communityId);
for ($j=0; $j < $options['topicnumber']; ++$j)
{
for ($k=0; $k < $options['number']; ++$k)
{
$ctc = new CommunityTopicComment();
$ctc->setMemberId(self::fetchRandomMemberId($memberIds));
$ctc->setCommunityTopicId(self::fetchRandomTopicId($topicIds));
$ctc->setBody('body');
$ctc->save();
$ctc->free();
$this->logSection('created a community topic comment', sprintf("%s", $communityId));
}
}
}
}
示例15: execute
/**
* @param array $arguments (optional)
* @param array $options (optional)
*/
public function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
afPortalStatePeer::deleteAllByIdXml($arguments['idxml']);
return 0;
}