• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfGetDB函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了wfGetDB函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: initialize

 public function initialize()
 {
     $dbr = wfGetDB(DB_MASTER);
     $res = $dbr->select('categorylinks', array('cl_to', 'COUNT(*) AS count'), array(), __METHOD__, array('GROUP BY' => 'cl_to', 'ORDER BY' => 'count DESC', 'LIMIT' => $this->limit));
     wfSuppressWarnings();
     // prevent PHP from bitching about strtotime()
     foreach ($res as $row) {
         $tag_name = Title::makeTitle(NS_CATEGORY, $row->cl_to);
         $tag_text = $tag_name->getText();
         if (strtotime($tag_text) == '') {
             // don't want dates to show up
             if ($row->count > $this->tags_highest_count) {
                 $this->tags_highest_count = $row->count;
             }
             $this->tags[$tag_text] = array('count' => $row->count);
         }
     }
     wfRestoreWarnings();
     // sort tag array by key (tag name)
     if ($this->tags_highest_count == 0) {
         return;
     }
     ksort($this->tags);
     /* and what if we have _1_ category? like on a new wiki with nteen articles, mhm? */
     if ($this->tags_highest_count == 1) {
         $coef = $this->tags_max_pts - $this->tags_min_pts;
     } else {
         $coef = ($this->tags_max_pts - $this->tags_min_pts) / (($this->tags_highest_count - 1) * 2);
     }
     foreach ($this->tags as $tag => $att) {
         $this->tags[$tag]['size'] = $this->tags_min_pts + ($this->tags[$tag]['count'] - 1) * $coef;
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:TagCloudClass.php


示例17: getSQL

 function getSQL()
 {
     $dbr = wfGetDB(DB_SLAVE);
     list($page, $redirect) = $dbr->tableNamesN('page', 'redirect');
     $sql = "SELECT 'BrokenRedirects'  AS type,\r\n\t\t                p1.page_namespace AS namespace,\r\n\t\t                p1.page_title     AS title,\r\n\t\t                rd_namespace,\r\n\t\t                rd_title\r\n\t\t           FROM {$redirect} AS rd\r\n                   JOIN {$page} p1 ON (rd.rd_from=p1.page_id)\r\n\t\t      LEFT JOIN {$page} AS p2 ON (rd_namespace=p2.page_namespace AND rd_title=p2.page_title )\r\n\t\t\t  \t  WHERE rd_namespace >= 0\r\n\t\t\t\t    AND p2.page_namespace IS NULL";
     return $sql;
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:7,代码来源:SpecialBrokenRedirects.php


示例18: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     extract($dbr->tableNames('page', 'categorylinks'));
     $name = $dbr->addQuotes($this->getName());
     return "SELECT {$name} as type, page_namespace AS namespace, page_title AS title, page_title AS value " . "FROM {$page} LEFT JOIN {$categorylinks} ON page_id=cl_from " . "WHERE cl_from IS NULL AND page_namespace={$this->requestedNamespace} AND page_is_redirect=0";
 }
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:7,代码来源:SpecialUncategorizedpages.php


示例19: setUp

 protected function setUp()
 {
     parent::setUp();
     $dbw = wfGetDB(DB_MASTER);
     $dbw->replace('interwiki', ['iw_prefix'], ['iw_prefix' => 'linksupdatetest', 'iw_url' => 'http://testing.com/wiki/$1', 'iw_api' => 'http://testing.com/w/api.php', 'iw_local' => 0, 'iw_trans' => 0, 'iw_wikiid' => 'linksupdatetest']);
     $this->setMwGlobals('wgRCWatchCategoryMembership', true);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:LinksUpdateTest.php


示例20: getSQL

 function getSQL()
 {
     $dbr = wfGetDB(DB_SLAVE);
     list($page, $templatelinks) = $dbr->tableNamesN('page', 'templatelinks');
     $sql = "SELECT 'Unusedtemplates' AS type, page_title AS title,\n\t\t\tpage_namespace AS namespace, 0 AS value\n\t\t\tFROM {$page}\n\t\t\tLEFT JOIN {$templatelinks}\n\t\t\tON page_namespace = tl_namespace AND page_title = tl_title\n\t\t\tWHERE page_namespace = 10 AND tl_from IS NULL\n\t\t\tAND page_is_redirect = 0";
     return $sql;
 }
开发者ID:rocLv,项目名称:conference,代码行数:7,代码来源:SpecialUnusedtemplates.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfGetDb函数代码示例发布时间:2022-05-23
下一篇:
PHP wfGetCaller函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap