當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wfGetDB函數代碼示例

本文整理匯總了PHP中wfGetDB函數的典型用法代碼示例。如果您正苦於以下問題:PHP wfGetDB函數的具體用法?PHP wfGetDB怎麽用?PHP wfGetDB使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wfGetDB函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     $fname = 'DoubleRedirectsPage::formatResult';
     $titleA = Title::makeTitle($result->namespace, $result->title);
     if ($result && !isset($result->nsb)) {
         $dbr =& wfGetDB(DB_SLAVE);
         $sql = $this->getSQLText($dbr, $result->namespace, $result->title);
         $res = $dbr->query($sql, $fname);
         if ($res) {
             $result = $dbr->fetchObject($res);
             $dbr->freeResult($res);
         }
     }
     if (!$result) {
         return '';
     }
     $titleB = Title::makeTitle($result->nsb, $result->tb);
     $titleC = Title::makeTitle($result->nsc, $result->tc);
     $linkA = $skin->makeKnownLinkObj($titleA, '', 'redirect=no');
     $edit = $skin->makeBrokenLinkObj($titleA, "(" . wfMsg("qbedit") . ")", 'redirect=no');
     $linkB = $skin->makeKnownLinkObj($titleB, '', 'redirect=no');
     $linkC = $skin->makeKnownLinkObj($titleC);
     $arr = $wgContLang->isRTL() ? '←' : '→';
     return "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}";
 }
開發者ID:k-hasan-19,項目名稱:wiki,代碼行數:26,代碼來源:SpecialDoubleRedirects.php

示例2: getWikiUsers

 /**
  * Get users with avatar who sign up on the wiki (include founder)
  *
  * @param integer $wikiId
  * @param integer $limit (number of users)
  * @return array $wikiUsers
  */
 protected function getWikiUsers($wikiId = null, $limit = 30)
 {
     global $wgSpecialsDB;
     wfProfileIn(__METHOD__);
     $wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
     $memKey = wfSharedMemcKey('userlogin', 'users_with_avatar', $wikiId);
     $wikiUsers = $this->wg->Memc->get($memKey);
     if (!is_array($wikiUsers)) {
         $wikiUsers = array();
         $db = wfGetDB(DB_SLAVE, array(), $wgSpecialsDB);
         $result = $db->select(array('user_login_history'), array('distinct user_id'), array('city_id' => $wikiId), __METHOD__, array('LIMIT' => $limit));
         while ($row = $db->fetchObject($result)) {
             $this->addUserToUserList($row->user_id, $wikiUsers);
         }
         $db->freeResult($result);
         // add founder if not exist
         $founder = WikiFactory::getWikiById($wikiId)->city_founding_user;
         if (!array_key_exists($founder, $wikiUsers)) {
             $this->addUserToUserList($founder, $wikiUsers);
         }
         $this->wg->Memc->set($memKey, $wikiUsers, WikiaResponse::CACHE_STANDARD);
     }
     wfProfileOut(__METHOD__);
     return $wikiUsers;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:32,代碼來源:UserLoginHelper.class.php

示例3: fixAllSwiftSyncData

function fixAllSwiftSyncData($dry, $limit)
{
    global $wgSwiftSyncDB, $method;
    $dbr = wfGetDB(DB_SLAVE, array(), $wgSwiftSyncDB);
    $res = $dbr->select(['image_sync_done'], ['id, city_id, img_action, img_src, img_dest, img_added, img_sync, img_error'], ['city_id' => 0], $method, ['ORDER BY' => 'id', 'LIMIT' => $limit]);
    $rows = array();
    while ($row = $dbr->fetchObject($res)) {
        $rows[] = $row;
    }
    $dbr->freeResult($res);
    print sprintf("Found %0d rows to fix \n", count($rows));
    foreach ($rows as $row) {
        print "Parsing " . $row->id . ", ";
        $image_path_dir = null;
        if (preg_match('/swift\\-backend\\/(.*)\\/images/', $row->img_dest, $data)) {
            $image_path_dir = $data[1];
        }
        if (empty($image_path_dir)) {
            print " cannot find image_path_dir \n";
            continue;
        }
        $image_path = sprintf("http://images.wikia.com/%s/images", $image_path_dir);
        $serialized_image_path = serialize($image_path);
        print "path: " . $serialized_image_path . ", ";
        $row->city_id = getCityIdByImagePath($serialized_image_path);
        if ($row->city_id > 0) {
            moveRecordToActiveQueue($row, $dry);
        } else {
            print " cannot find city_id \n";
        }
    }
}
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:32,代碼來源:fixswiftsyncdata.php

示例4: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     list($categorylinks, $page) = $dbr->tableNamesN('categorylinks', 'page');
     $name = $dbr->addQuotes($this->getName());
     return "\n\t\t\tSELECT\n\t\t\t\t{$name} as type,\n\t\t\t\t" . NS_CATEGORY . " as namespace,\n\t\t\t\tcl_to as title,\n\t\t\t\tCOUNT(*) as value\n\t\t\tFROM {$categorylinks}\n\t\t\tLEFT JOIN {$page} ON cl_to = page_title AND page_namespace = " . NS_CATEGORY . "\n\t\t\tWHERE page_title IS NULL\n\t\t\tGROUP BY 1,2,3\n\t\t\t";
 }
開發者ID:negabaro,項目名稱:alfresco,代碼行數:7,代碼來源:SpecialWantedcategories.php

示例5: execute

 function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $this->getOutput()->addModuleStyles('mediawiki.special.pagesWithProp');
     $request = $this->getRequest();
     $propname = $request->getVal('propname', $par);
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('page_props', 'pp_propname', '', __METHOD__, array('DISTINCT', 'ORDER BY' => 'pp_propname'));
     $propnames = array();
     foreach ($res as $row) {
         $propnames[$row->pp_propname] = $row->pp_propname;
     }
     $form = new HTMLForm(array('propname' => array('type' => 'selectorother', 'name' => 'propname', 'options' => $propnames, 'default' => $propname, 'label-message' => 'pageswithprop-prop', 'required' => true)), $this->getContext());
     $form->setMethod('get');
     $form->setSubmitCallback(array($this, 'onSubmit'));
     $form->setWrapperLegendMsg('pageswithprop-legend');
     $form->addHeaderText($this->msg('pageswithprop-text')->parseAsBlock());
     $form->setSubmitTextMsg('pageswithprop-submit');
     $form->prepareForm();
     $form->displayForm(false);
     if ($propname !== '' && $propname !== null) {
         $form->trySubmit();
     }
 }
開發者ID:Tarendai,項目名稱:spring-website,代碼行數:25,代碼來源:SpecialPagesWithProp.php

示例6: getSQL

 function getSQL()
 {
     global $wgCountCategorizedImagesAsUsed, $wgDBtype;
     $dbr = wfGetDB(DB_SLAVE);
     switch ($wgDBtype) {
         case 'mysql':
             $epoch = 'UNIX_TIMESTAMP(img_timestamp)';
             break;
         case 'oracle':
             $epoch = '((trunc(img_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
             break;
         case 'sqlite':
             $epoch = 'img_timestamp';
             break;
         default:
             $epoch = 'EXTRACT(epoch FROM img_timestamp)';
     }
     if ($wgCountCategorizedImagesAsUsed) {
         list($page, $image, $imagelinks, $categorylinks) = $dbr->tableNamesN('page', 'image', 'imagelinks', 'categorylinks');
         return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, {$epoch} as value,\n\t\t\t\t\t\timg_user, img_user_text,  img_description\n\t\t\t\t\tFROM ((({$page} AS I LEFT JOIN {$categorylinks} AS L ON I.page_id = L.cl_from)\n\t\t\t\t\t\tLEFT JOIN {$imagelinks} AS P ON I.page_title = P.il_to)\n\t\t\t\t\t\tINNER JOIN {$image} AS G ON I.page_title = G.img_name)\n\t\t\t\t\tWHERE I.page_namespace = " . NS_FILE . " AND L.cl_from IS NULL AND P.il_to IS NULL";
     } else {
         list($image, $imagelinks) = $dbr->tableNamesN('image', 'imagelinks');
         return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, {$epoch} as value,\n\t\t\t\timg_user, img_user_text,  img_description\n\t\t\t\tFROM {$image} LEFT JOIN {$imagelinks} ON img_name=il_to WHERE il_to IS NULL ";
     }
 }
開發者ID:rocLv,項目名稱:conference,代碼行數:25,代碼來源:SpecialUnusedimages.php

示例7: getSQL

 function getSQL()
 {
     $dbr = wfGetDB(DB_SLAVE);
     list($page, $categorylinks) = $dbr->tableNamesN('page', 'categorylinks');
     $ns = NS_IMAGE;
     return "SELECT 'Uncategorizedimages' AS type, page_namespace AS namespace,\r\n\t\t\t\tpage_title AS title, page_title AS value\r\n\t\t\t\tFROM {$page} LEFT JOIN {$categorylinks} ON page_id = cl_from\r\n\t\t\t\tWHERE cl_from IS NULL AND page_namespace = {$ns} AND page_is_redirect = 0";
 }
開發者ID:Jobava,項目名稱:diacritice-meta-repo,代碼行數:7,代碼來源:SpecialUncategorizedimages.php

示例8: getSQL

 function getSQL()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $page = $dbr->tableName('page');
     $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, \n\t\t\t0 AS value FROM {$page} WHERE page_is_redirect = 1";
     return $sql;
 }
開發者ID:amjadtbssm,項目名稱:website,代碼行數:7,代碼來源:SpecialListredirects.php

示例9: moveToExternal

function moveToExternal($cluster, $maxID)
{
    $fname = 'moveToExternal';
    $dbw =& wfGetDB(DB_MASTER);
    print "Moving {$maxID} text rows to external storage\n";
    $ext = new ExternalStoreDB();
    for ($id = 1; $id <= $maxID; $id++) {
        if (!($id % REPORTING_INTERVAL)) {
            print "{$id}\n";
            wfWaitForSlaves(5);
        }
        $row = $dbw->selectRow('text', array('old_flags', 'old_text'), array('old_id' => $id, "old_flags NOT LIKE '%external%'"), $fname);
        if (!$row) {
            # Non-existent or already done
            continue;
        }
        # Resolve stubs
        $flags = explode(',', $row->old_flags);
        if (in_array('object', $flags) && substr($row->old_text, 0, strlen(STUB_HEADER)) === STUB_HEADER) {
            resolveStub($id, $row->old_text, $row->old_flags);
            continue;
        }
        $url = $ext->store($cluster, $row->old_text);
        if (!$url) {
            print "Error writing to external storage\n";
            exit;
        }
        if ($row->old_flags === '') {
            $flags = 'external';
        } else {
            $flags = "{$row->old_flags},external";
        }
        $dbw->update('text', array('old_flags' => $flags, 'old_text' => $url), array('old_id' => $id), $fname);
    }
}
開發者ID:BackupTheBerlios,項目名稱:openzaurus-svn,代碼行數:35,代碼來源:moveToExternal.php

示例10: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     extract($dbr->tableNames('categorylinks', 'page'));
     $name = $dbr->addQuotes($this->getName());
     return "\n\t\t\tSELECT\n\t\t\t\t{$name} as type,\n\t\t\t\t" . NS_CATEGORY . " as namespace,\n\t\t\t\tcl_to as title,\n\t\t\t\tCOUNT(*) as value\n\t\t\tFROM {$categorylinks}\n\t\t\tGROUP BY cl_to\n\t\t\t";
 }
開發者ID:k-hasan-19,項目名稱:wiki,代碼行數:7,代碼來源:SpecialMostlinkedcategories.php

示例11: execute

 public function execute()
 {
     $this->output("Delete Orphaned Revisions\n");
     $report = $this->hasOption('report');
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin(__METHOD__);
     list($page, $revision) = $dbw->tableNamesN('page', 'revision');
     # Find all the orphaned revisions
     $this->output("Checking for orphaned revisions...");
     $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id " . "WHERE page_namespace IS NULL";
     $res = $dbw->query($sql, 'deleteOrphanedRevisions');
     # Stash 'em all up for deletion (if needed)
     $revisions = array();
     foreach ($res as $row) {
         $revisions[] = $row->rev_id;
     }
     $count = count($revisions);
     $this->output("found {$count}.\n");
     # Nothing to do?
     if ($report || $count == 0) {
         $dbw->commit(__METHOD__);
         exit(0);
     }
     # Delete each revision
     $this->output("Deleting...");
     $this->deleteRevs($revisions, $dbw);
     $this->output("done.\n");
     # Close the transaction and call the script to purge unused text records
     $dbw->commit(__METHOD__);
     $this->purgeRedundantText(true);
 }
開發者ID:MediaWiki-stable,項目名稱:1.26.1,代碼行數:31,代碼來源:deleteOrphanedRevisions.php

示例12: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     extract($dbr->tableNames('page', 'pagelinks'));
     $sql = "SELECT 'BrokenRedirects'  AS type,\n\t\t                p1.page_namespace AS namespace,\n\t\t                p1.page_title     AS title,\n\t\t                pl_namespace,\n\t\t                pl_title\n\t\t           FROM {$pagelinks} AS pl\n                   JOIN {$page} p1 ON (p1.page_is_redirect=1 AND pl.pl_from=p1.page_id)\n\t\t      LEFT JOIN {$page} AS p2 ON (pl_namespace=p2.page_namespace AND pl_title=p2.page_title )\n    \t\t                WHERE p2.page_namespace IS NULL";
     return $sql;
 }
開發者ID:puring0815,項目名稱:OpenKore,代碼行數:7,代碼來源:SpecialBrokenRedirects.php

示例13: fetchRegexData

 protected static function fetchRegexData($mode)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $phrases = array();
     /* first, check if regex string is already stored in memcache */
     $key_clause = $mode == SPAMREGEX_SUMMARY ? 'Summary' : 'Textbox';
     $key = wfSpamRegexCacheKey('spamRegexCore', 'spamRegex', $key_clause);
     $cached = $wgMemc->get($key);
     if (!$cached) {
         /* fetch data from db, concatenate into one string, then fill cache */
         $field = $mode == SPAMREGEX_SUMMARY ? 'spam_summary' : 'spam_textbox';
         $dbr = wfGetDB(DB_SLAVE);
         $res = $dbr->select('spam_regex', 'spam_text', array($field => 1), __METHOD__);
         while ($row = $res->fetchObject()) {
             $concat = $row->spam_text;
             $phrases[] = "/" . $concat . "/i";
         }
         $wgMemc->set($key, $phrases, 0);
         $res->free();
     } else {
         /* take from cache */
         $phrases = $cached;
     }
     wfProfileOut(__METHOD__);
     return $phrases;
 }
開發者ID:yusufchang,項目名稱:app,代碼行數:27,代碼來源:SpamRegexCore.php

示例14: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'vars', 'rcid', 'logid');
     // "Anti-DoS"
     if (!$this->getUser()->isAllowed('abusefilter-modify')) {
         $this->dieUsageMsg('permissiondenied');
     }
     if ($params['vars']) {
         $vars = FormatJson::decode($params['vars'], true);
     } elseif ($params['rcid']) {
         $dbr = wfGetDB(DB_SLAVE);
         $row = $dbr->selectRow('recentchanges', '*', array('rc_id' => $params['rcid']), __METHOD__);
         if (!$row) {
             $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
         }
         $vars = AbuseFilter::getVarsFromRCRow($row);
     } elseif ($params['logid']) {
         $dbr = wfGetDB(DB_SLAVE);
         $row = $dbr->selectRow('abuse_filter_log', '*', array('afl_id' => $params['logid']), __METHOD__);
         if (!$row) {
             $this->dieUsage("There is no abuselog entry with the id ``{$params['logid']}''", 'nosuchlogid');
         }
         $vars = AbuseFilter::loadVarDump($row->afl_var_dump);
     }
     if (AbuseFilter::checkSyntax($params['filter']) !== true) {
         $this->dieUsage('The filter has invalid syntax', 'badsyntax');
     }
     $result = AbuseFilter::checkConditions($params['filter'], $vars);
     $this->getResult()->addValue(null, $this->getModuleName(), array('result' => $result));
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:31,代碼來源:ApiAbuseFilterCheckMatch.php

示例15: getDB

 /**
  * @return DatabaseBase
  */
 public function getDB()
 {
     if ($this->database === null) {
         $this->database = wfGetDB(DB_SLAVE);
     }
     return $this->database;
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:10,代碼來源:Search.php


注:本文中的wfGetDB函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。