本文整理汇总了PHP中sfDatabaseManager::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP sfDatabaseManager::getDatabase方法的具体用法?PHP sfDatabaseManager::getDatabase怎么用?PHP sfDatabaseManager::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfDatabaseManager
的用法示例。
在下文中一共展示了sfDatabaseManager::getDatabase方法的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: setup
public function setup()
{
$db = $this->databasemanager->getDatabase('doctrine');
/* @var $db sfDoctrineDatabase */
// Special Handling for postgre, since droping even when closing the connection, fails with
// SQLSTATE[55006]: Object in use: 7 ERROR: database "cs_doctrine_act_as_sortable_test" is being accessed by other users DETAIL: There are 1 other session(s) using the database.
if ($db->getDoctrineConnection() instanceof Doctrine_Connection_Pgsql) {
try {
$db->getDoctrineConnection()->createDatabase();
} catch (Exception $e) {
}
$export = new Doctrine_Export_Pgsql($db->getDoctrineConnection());
$import = new Doctrine_Import_Pgsql($db->getDoctrineConnection());
$tablenames = array(SortableArticleTable::getInstance()->getTableName(), SortableArticleUniqueByTable::getInstance()->getTableName(), SortableArticleCategoryTable::getInstance()->getTableName());
foreach ($tablenames as $tablename) {
if ($import->tableExists($tablename)) {
$export->dropTable($tablename);
}
}
} else {
try {
// ignore error if database does not yet exist (clean CI-env)
$db->getDoctrineConnection()->dropDatabase();
} catch (Exception $e) {
}
$db->getDoctrineConnection()->createDatabase();
}
// Using Doctrine instead of Doctrine_Core keeps it symfony 1.2 compatible, which uses
Doctrine::loadModels(dirname(__FILE__) . '/../fixtures/project/lib/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
Doctrine::loadData(dirname(__FILE__) . '/../fixtures/project/data/fixtures/categories.yml');
}
示例3: execute
protected function execute($arguments = array(), $options = array())
{
$this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
$this->context = sfContext::createInstance($this->configuration);
$databaseManager = new sfDatabaseManager($this->configuration);
$dbdsn = $databaseManager->getDatabase('propel')->getParameter('dsn');
$dbusername = $databaseManager->getDatabase('propel')->getParameter('username');
$dbpassword = $databaseManager->getDatabase('propel')->getParameter('password');
$dbname = preg_replace('/^.*dbname=([^;=]+).*$/', '${1}', $dbdsn);
ConfigurationHelper::load();
$backup_method = ConfigurationHelper::getParameter('Backup', 'backup_method');
$this->logSection('tempos', sprintf('Backup method: %s', $backup_method), 1024);
if ($backup_method == 'ftp') {
$backupname = 'tempos-backup.sql';
$configname = ConfigurationHelper::getDefaultConfigurationFileName();
$configpath = ConfigurationHelper::getDefaultConfigurationFilePath();
copy($configpath, '/tmp/' . $configname);
chdir('/tmp');
system(sprintf('mysqldump --user=%s --password=%s %s > %s', escapeshellarg($dbusername), escapeshellarg($dbpassword), escapeshellarg($dbname), escapeshellarg($backupname)));
$tmpfilename = 'tempos-backup-' . date('Y-m-d') . '.tar.gz';
system(sprintf('tar zcf %s %s %s', escapeshellarg($tmpfilename), escapeshellarg($backupname), escapeshellarg($configname)));
unlink($backupname);
unlink($configname);
try {
FTPHelper::backupFile($tmpfilename);
} catch (Exception $ex) {
unlink($tmpfilename);
throw $ex;
}
unlink($tmpfilename);
}
}
示例4: execute
/**
* opDumpMemberTask::execute()
*
* @param array $arguments
* @param array $options
* @return
*/
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$doctrineConnection = $databaseManager->getDatabase($options['connection'])->getDoctrineConnection();
$fp = fopen(sfConfig::get('sf_data_dir') . '/memberlist.csv', 'w');
// gets member list(using pure SQL)
$sql = 'select * from member';
$members = $doctrineConnection->fetchAll($sql, array());
foreach ($members as $member) {
$line = array();
$memberObj = new Member();
$memberObj->fromArray($member);
// nickname is required
$name = $memberObj->getName();
if (empty($name)) {
continue;
}
$line[] = $memberObj->getId();
$line[] = $name;
$email = trim($memberObj->getConfig('pc_address'));
if (empty($email)) {
$email = $memberObj->getConfig('mobile_address');
}
if (empty($email)) {
continue;
}
$line[] = trim($email);
fputcsv($fp, $line, ',', '"');
}
fclose($fp);
}
示例5: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$dns = $databaseManager->getDatabase($options['connection'])->getParameter("dsn");
preg_match_all("/mysql:[a-z]+=([a-z\\.]+);dbname=([a-z]+)/", $dns, $matchesarray);
$hostname = $matchesarray[1][0];
$dbname = $matchesarray[2][0];
$username = $databaseManager->getDatabase($options['connection'])->getParameter("username");
$password = $databaseManager->getDatabase($options['connection'])->getParameter("password");
$this->getFilesystem()->mkdirs("data/dumps/" . $hostname);
system("mysqldump -h " . $hostname . " -u " . $username . " -p" . $password . " --complete-insert --no-create-info " . $dbname . " > data/dumps/" . $hostname . "/" . $dbname . ".sql");
}
示例6: execute
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();
$sql = 'SELECT id FROM member WHERE is_active != 0';
$where = array();
if ( $options['min'] && $options['max'] && $options['min'] <= $options['max'])
{
$sql .= ' AND id BETWEEN ? AND ?';
$where = array(intval($options['min']),intval($options['max']));
}
$memberIds = $this->conn->fetchColumn($sql, $where);
$this->setContents();
foreach ($memberIds as $memberid)
{
$randomtime = $this->makeRandomTime($options['date'],$options['number']);
for ($i=0; $i<$options['number']; ++$i)
{
$title=$this->makeRandomContents('title',$options['titlecount']);
$body=$this->makeRandomContents('body',$options['bodycount']);
$diary = new Diary();
$diary->setMemberId($memberid);
$diary->setTitle($title);
$diary->setBody($body);
$diary->setPublicFlag(1);
$diary->setCreatedAt($randomtime[$i]);
$diary->setUpdatedAt($randomtime[$i]);
$diary->save();
$diary->free();
$this->logSection('posted a diary', sprintf('%s %s', $memberid, $randomtime[$i]));
}
}
}
示例7: 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();
}
}
}
示例8: 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)");
}
示例9: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$cleanDb = new ADCleanDBRequest(ADCleanDBRequest::CINEMAS_URL);
$cleanDb->send();
$cleanDb->cleanCinemasTables();
sleep(1);
$cleanDb = new ADCleanDBRequest(ADCleanDBRequest::SECTIONS_URL);
$cleanDb->send();
$cleanDb->cleanSectionsTables();
sleep(1);
$cleanDb = new ADCleanDBRequest(ADCleanDBRequest::FILMS_URL);
$cleanDb->send();
$cleanDb->cleanFilmsTables();
sleep(1);
$cleanDb = new ADCleanDBRequest(ADCleanDBRequest::PACKAGES_URL);
$cleanDb->send();
$cleanDb->cleanPackagesTables();
sleep(1);
$cleanDb = new ADCleanDBRequest(ADCleanDBRequest::SCREENINGS_URL);
$cleanDb->send();
$cleanDb->cleanScreeningsTables();
echo 'DB clean up succesful';
}
示例10: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
// add networks from config file to the givel cluster (optional)
$flag = 0;
//write or not to stdout
if ($options['cluster_id']) {
$cluster_id = $options['cluster_id'];
$flag = 1;
} else {
$default_cluster = EtvaClusterPeer::retrieveDefaultCluster();
$cluster_id = $default_cluster->getId();
}
error_log("LOADCONFTASK[INFO] Loading config file");
error_log($cluster_id);
$model = Etva::getEtvaModelFile();
$networks = isset($model['networks']) ? $model['networks'] : $model[ucfirst('networks')];
if ($this->initialize_networks($networks, $cluster_id)) {
if ($flag == 0) {
echo "Done!\n";
}
return 1;
} else {
if ($flag == 0) {
echo "Failed!\n";
}
return 0;
}
}
示例11: 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();
}
}
}
示例12: 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));
}
}
}
}
示例13: 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
}
示例14: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
if ($options['server'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SERVER_, $options['server']);
}
if ($options['port'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_PORT_, $options['port']);
}
if ($options['security-type'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SECURITY_, $options['security-type']);
}
if ($options['use-auth'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USE_AUTH_, $options['use-auth']);
}
if ($options['username'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USERNAME_, $options['username']);
}
if ($options['password'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_KEY_, $options['password']);
}
return;
}
示例15: 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