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


PHP wfGetDb函数代码示例

本文整理汇总了PHP中wfGetDb函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetDb函数的具体用法?PHP wfGetDb怎么用?PHP wfGetDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: execute

 public function execute($subPage)
 {
     global $wgRequest, $wgUser;
     $zip = (int) $wgRequest->getVal('zip');
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     if ($wgRequest->getVal('store')) {
         $dbw = wfGetDb(DB_MASTER);
         $res = $dbw->insert('cl_errors', array('cle_zip' => $zip, 'cle_comment' => $wgRequest->getVal('comment')), __METHOD__, array());
         $out->addHtml('Thank you!');
     } else {
         $out->addHtml('<form method=post action="/wiki/Special:CongressFail">');
         $out->addHtml('<div>');
         $out->addHtml('<div>');
         if ($zip != 0) {
             $out->addHtml('ZIP Code (will be recorded): ' . $zip);
             $out->addHtml('<input type=hidden name=zip value=' . $zip . '>');
         } else {
             $out->addHtml('ZIP code: <input name=zip>');
         }
         $out->addHtml('</div>');
         $out->addHtml('Tell us what went wrong: <input type=text size=100 name=comment maxlength=255>');
         $out->addHtml('</div>');
         $out->addHtml('<div>');
         $out->addHtml('<input type=submit name=store value="Send Error Report">');
         $out->addHtml('</div>');
         $out->addHtml('</form>');
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:SpecialCongressFail.php

示例2: execute

 public function execute()
 {
     $dbw = wfGetDb(DB_MASTER);
     // Determining what groups the account was in before the change
     // would be difficult and unnecessary 99.9% of the time, so we just
     // assume the account was in no other groups
     $params = array('grant' => "\nbot", 'revoke' => "bot\n");
     $logrows = $dbw->select('logging', array('log_id', 'log_action'), array('log_type' => 'makebot', 'log_action' => array('grant', 'revoke')), __METHOD__);
     $count = $logrows->numRows();
     $this->output("Updating {$count} entries in the logging table\n");
     $batch = 0;
     foreach ($logrows as $row) {
         $dbw->update('logging', array('log_action' => 'rights', 'log_type' => 'rights', 'log_params' => $params[$row->log_action]), array('log_id' => $row->log_id), __METHOD__);
         $batch++;
         if ($batch == 100) {
             wfWaitForSlaves(5);
             $batch = 0;
         }
     }
     $rcrows = $dbw->select('recentchanges', array('rc_id', 'rc_log_action'), array('rc_log_type' => 'makebot', 'rc_log_action' => array('grant', 'revoke')), __METHOD__);
     $count = $rcrows->numRows();
     $this->output("Updating {$count} entries in the recentchanges table\n");
     foreach ($rcrows as $row) {
         $dbw->update('recentchanges', array('rc_log_action' => 'rights', 'rc_log_type' => 'rights', 'rc_params' => $params[$row->rc_log_action]), array('rc_id' => $row->rc_id), __METHOD__);
     }
     $this->output("Done!\n");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:migrateBotlog.php

示例3: execute

 /**
  * Extracts the title, token, and reason from the request parameters and invokes
  * the local delete() function with these as arguments. It does not make use of 
  * the delete function specified by Article.php. If the deletion succeeds, the 
  * details of the article deleted and the reason for deletion are added to the 
  * result object.
  */
 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     if (!$titleObj->exists()) {
         $this->dieUsageMsg(array('notanarticle'));
     }
     $articleObj = new Article($titleObj);
     $reason = isset($params['reason']) ? $params['reason'] : NULL;
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = self::delete($articleObj, $params['token'], $reason);
     if (!empty($retval)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(current($retval));
     }
     $dbw->commit();
     $r = array('title' => $titleObj->getPrefixedText(), 'reason' => $reason);
     $this->getResult()->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:39,代码来源:ApiDelete.php

示例4: send

 function send($recipients, $headers, $body)
 {
     $this->_sanitizeHeaders($headers);
     list($from, $textHeaders) = $this->prepareHeaders($headers);
     $priority = 0;
     if (isset($headers['X-Priority'])) {
         $priority = $headers['X-Priority'];
     }
     $category = '';
     if (isset($headers['X-Msg-Category'])) {
         $category = $headers['X-Msg-Category'];
     }
     global $wgCityId, $wgWikiaMailerDB;
     $wgCityId = $wgCityId == null ? 0 : $wgCityId;
     // fake city-id for contractor/staff.
     // FB:4431 Write mail to archive database now
     $dbw = wfGetDb(DB_MASTER, array(), $wgWikiaMailerDB);
     $dbw->begin(__METHOD__);
     foreach ($recipients as $recipient) {
         // TODO: SHOULD WE FILTER BASED ON BLOCKS / SPAMS HERE?  FOR NOW WE WILL LET SENDGRID HANDLE THAT.
         $dbw->insert(self::$MAIL_TABLE_NAME, array('src' => $from, 'subj' => $headers['Subject'], 'dst' => $recipient, 'hdr' => $textHeaders, 'msg' => $body, 'city_id' => $wgCityId, 'priority' => $priority, 'category' => $category), __METHOD__);
         // Add postback token so that we can verify that any postback actually comes from SendGrid.
         $emailId = $dbw->insertId();
         $postbackToken = wfGetEmailPostbackToken($emailId, $recipient);
         $textHeaders .= $this->sep . "X-CallbackToken: " . $postbackToken;
         $dbw->update(self::$MAIL_TABLE_NAME, array('hdr' => $textHeaders), array('id' => $emailId), __METHOD__);
         wfDebugLog("enotif", __METHOD__ . ": email added to database with data: {$recipient} {$from} {$headers['Subject']}", true);
     }
     $dbw->commit(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:wikiadb.php

示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $dbw = wfGetDb(DB_MASTER);
     $dbw->insert('cl_errors', array('cle_zip' => $params['zip'], 'cc_comment' => $params['comment']), __METHOD__, array());
     $this->getResult()->addValue(null, $this->getModuleName(), 'OK');
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:ApiCongressLookup.php

示例6: __construct

 /**
  * Constructor
  *
  * @var $resourceType String The calling application or type of resource, conceptually like a namespace
  * @var $user User object, the current user
  * @var $expirationTime Integer (optional) How long should a checkout last, in seconds
  */
 public function __construct($resourceType, $user, $expirationTime = null)
 {
     // All database calls are to the master, since the whole point of this class is maintaining
     // concurrency. Most reads should come from cache anyway.
     $this->dbw = wfGetDb(DB_MASTER);
     $this->user = $user;
     // TODO: create a registry of all valid resourceTypes that client app can add to.
     $this->resourceType = $resourceType;
     $this->setExpirationTime($expirationTime);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:ConcurrencyCheck.php

示例7: getWikiArticles

function getWikiArticles()
{
    $searchpages = array("'Spam-blacklist'", "'Spam-whitelist'", "'Spam_blacklist'", "'Spam_whitelist'", "'External_links_whitelist'");
    $db = wfGetDb(DB_SLAVE);
    $res = $db->select(array('page'), array('page_id', 'page_title'), array('page_namespace	= 8', 'page_title in (' . implode(',', $searchpages) . ')'), 'count_average_title', array('ORDER BY' => 'page_id DESC'));
    $articles = array();
    while ($article = $res->fetchObject()) {
        $articles[$article->page_id] = $article->page_title;
    }
    return $articles;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:blackListMessageChecks.php

示例8: newFromDBResult

 /**
  * Creates and returns a new SWLChangeSet instance from a database result
  * obtained by doing a select on swl_sets. 
  * 
  * @since 0.1
  * 
  * @param $set
  * 
  * @return SWLChangeSet
  */
 public static function newFromDBResult($set)
 {
     $changeSet = new SWLChangeSet(SMWDIWikiPage::newFromTitle(Title::newFromID($set->edit_page_id)), null, null, null, $set->spe_set_id, new SWLEdit($set->edit_page_id, $set->edit_user_name, $set->edit_time, $set->edit_id));
     $dbr = wfGetDb(DB_SLAVE);
     $changes = $dbr->select('swl_changes', array('change_id', 'change_property', 'change_old_value', 'change_new_value'), array('change_set_id' => $set->spe_set_id));
     foreach ($changes as $change) {
         $property = SMWDIProperty::doUnserialize($change->change_property, '__pro');
         $changeSet->addChange($property, SWLPropertyChange::newFromSerialization($property, $change->change_old_value, $change->change_new_value));
     }
     return $changeSet;
 }
开发者ID:nilsdornblut,项目名称:SemanticWatchlist,代码行数:21,代码来源:SWL_ChangeSet.php

示例9: __construct

 public function __construct($options)
 {
     // load command line options
     $this->options = $options;
     global $wgDBname;
     $this->force = isset($options['force']);
     $this->quick = isset($options['quick']);
     $this->databaseName = isset($options['database']) ? $options['database'] : $wgDBname;
     $this->db = wfGetDb(DB_SLAVE, array(), $this->databaseName);
     $this->walker = new DatabaseWalker_UsingShow($this->db);
     $this->script = new SqlScript();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:convert.php

示例10: displayDictionaryPage

 /**
  * Displays some shorts statistics about the dictionary page.
  *
  * @since 0.4
  *
  * @param Article $article
  * @param Title $title
  */
 protected static function displayDictionaryPage(Article &$article, Title $title)
 {
     global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages;
     $dbr = wfGetDb(DB_SLAVE);
     $res = $dbr->select('live_translate_memories', array('memory_lang_count', 'memory_tu_count'), array('memory_location' => $title->getFullText()), array('LIMIT' => 1));
     foreach ($res as $tm) {
         break;
     }
     if ($tm->memory_tu_count == 0) {
         $wgOut->addWikiMsg('livetranslate-dictionary-empty');
     } else {
         $wgOut->addWikiMsg('livetranslate-dictionary-count', $wgLang->formatNum($tm->memory_tu_count), $wgLang->formatNum($tm->memory_lang_count));
         /*
         $notAllowedLanguages = array();
         
         foreach ( $tus[0]->getVariants() as $languageCode => $translations ) {
         	$languageCode = strtolower( $languageCode );
         	$mappings = LiveTranslateFunctions::getInputLangMapping();
         
         	if ( array_key_exists( $languageCode, $mappings ) ) {
         		$languageCode = $mappings[$languageCode];
         	}
         
         	if ( !in_array( $languageCode, $egLiveTranslateLanguages ) ) {
         		$notAllowedLanguages[] = $languageCode;
         	}
         }
         
         if ( count( $notAllowedLanguages ) > 0 ) {
         	$languages = Language::getLanguageNames( false );
         
         	foreach ( $notAllowedLanguages as &$notAllowedLang ) {
         		if ( array_key_exists( $notAllowedLang, $languages ) ) {
         			$notAllowedLang = $languages[$notAllowedLang];
         		}
         	}
         
         	$wgOut->addHTML(
         		Html::element(
         			'span',
         			array( 'style' => 'color:darkred' ),
         			wfMsgExt( 'livetranslate-dictionary-unallowed-langs', 'parsemag', $wgLang->listToText( $notAllowedLanguages ), count( $notAllowedLanguages ) )
         		)
         	);
         }
         */
     }
     if ($wgUser->isAllowed('managetms')) {
         $wgOut->addHTML(Html::element('a', array('href' => Title::newFromText('Special:LiveTranslate')->getInternalURL()), wfMsg('livetranslate-dictionary-goto-edit')));
     }
 }
开发者ID:JeroenDeDauw,项目名称:LiveTranslate,代码行数:59,代码来源:LiveTranslate.hooks.php

示例11: __construct

 public function __construct($title)
 {
     global $wgUser;
     $this->title = $title;
     $this->dbr =& wfGetDb(DB_SLAVE);
     $this->skin = $wgUser->getSkin();
     $this->families = array();
     $this->numSpouseFamilies = 0;
     $this->selfTag = '';
     $this->spouseTag = '';
     $this->stdPlaces = null;
     $this->prevLastFamilyEndpoint = null;
     $this->loadPedigree();
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:14,代码来源:GetJSONData.php

示例12: execute

 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->isAllowed('undelete')) {
         $this->dieUsageMsg(array('permdenied-undelete'));
     }
     if ($wgUser->isBlocked()) {
         $this->dieUsageMsg(array('blockedtext'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     // Convert timestamps
     if (!is_array($params['timestamps'])) {
         $params['timestamps'] = array($params['timestamps']);
     }
     foreach ($params['timestamps'] as $i => $ts) {
         $params['timestamps'][$i] = wfTimestamp(TS_MW, $ts);
     }
     $pa = new PageArchive($titleObj);
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = $pa->undelete(isset($params['timestamps']) ? $params['timestamps'] : array(), $params['reason']);
     if (!is_array($retval)) {
         $this->dieUsageMsg(array('cannotundelete'));
     }
     $dbw->commit();
     $info['title'] = $titleObj->getPrefixedText();
     $info['revisions'] = $retval[0];
     $info['fileversions'] = $retval[1];
     $info['reason'] = $retval[2];
     $this->getResult()->addValue(null, $this->getModuleName(), $info);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:49,代码来源:ApiUndelete.php

示例13: execute

 public function execute()
 {
     $start = intval($this->getOption('start', 0));
     $maxlag = intval($this->getOption('maxlag', 5));
     $dbr = wfGetDb(DB_SLAVE);
     $maxUserID = $dbr->selectField('user', 'MAX(user_id)', false);
     $this->output("Starting from user_id {$start} of {$maxUserID}\n");
     for ($i = $start; $i < $maxUserID; $i++) {
         $this->fixUser($i);
         if ($i % self::REPORTING_INTERVAL == 0) {
             $this->output("{$i}\n");
             wfWaitForSlaves($maxlag);
         }
     }
     $this->output("All done\n");
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:post-switchover.php

示例14: execute

 public function execute()
 {
     if (!$this->hasArg()) {
         $this->error("No query specified. Specify the query as a command line parameter.", true);
     }
     $query = $this->getArg();
     $wait = $this->getOption('wait', 5);
     $n = 1;
     $dbw = wfGetDb(DB_MASTER);
     do {
         $this->output("Batch {$n}: ");
         $n++;
         $dbw->query($query, __METHOD__);
         $affected = $dbw->affectedRows();
         $this->output("{$affected} rows\n");
         wfWaitForSlaves($wait);
     } while ($affected > 0);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:18,代码来源:runBatchedQuery.php

示例15: __construct

 public function __construct($options)
 {
     // load command line options
     $this->options = $options;
     global $wgDBname;
     //		$this->force = isset($options['force']);
     //		$this->quick = isset($options['quick']);
     $this->short = isset($options['short']);
     $this->verbose = isset($options['verbose']);
     $this->databaseName = isset($options['database']) ? $options['database'] : $wgDBname;
     $this->clusterName = isset($options['cluster']) ? $options['cluster'] : $this->databaseName;
     $this->db = wfGetDb(DB_SLAVE, array(), $this->clusterName);
     if (!$this->db->selectDB($this->databaseName)) {
         $this->db = false;
     }
     $this->walker = new DatabaseWalker_UsingShow($this->db);
     $this->script = new SqlScript();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:checktbl.php


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