本文整理汇总了PHP中IDatabase::selectFieldValues方法的典型用法代码示例。如果您正苦于以下问题:PHP IDatabase::selectFieldValues方法的具体用法?PHP IDatabase::selectFieldValues怎么用?PHP IDatabase::selectFieldValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::selectFieldValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invalidatePages
/**
* Invalidate the cache of a list of pages from a single namespace.
* This is intended for use by subclasses.
*
* @param IDatabase $dbw
* @param int $namespace Namespace number
* @param array $dbkeys
*/
public static function invalidatePages(IDatabase $dbw, $namespace, array $dbkeys)
{
if ($dbkeys === []) {
return;
}
$dbw->onTransactionIdle(function () use($dbw, $namespace, $dbkeys) {
$services = MediaWikiServices::getInstance();
$lbFactory = $services->getDBLoadBalancerFactory();
// Determine which pages need to be updated.
// This is necessary to prevent the job queue from smashing the DB with
// large numbers of concurrent invalidations of the same page.
$now = $dbw->timestamp();
$ids = $dbw->selectFieldValues('page', 'page_id', ['page_namespace' => $namespace, 'page_title' => $dbkeys, 'page_touched < ' . $dbw->addQuotes($now)], __METHOD__);
if (!$ids) {
return;
}
$batchSize = $services->getMainConfig()->get('UpdateRowsPerQuery');
$ticket = $lbFactory->getEmptyTransactionTicket(__METHOD__);
foreach (array_chunk($ids, $batchSize) as $idBatch) {
$dbw->update('page', ['page_touched' => $now], ['page_id' => $idBatch, 'page_touched < ' . $dbw->addQuotes($now)], __METHOD__);
$lbFactory->commitAndWaitForReplication(__METHOD__, $ticket);
}
}, __METHOD__);
}