本文整理汇总了PHP中ResultWrapper类的典型用法代码示例。如果您正苦于以下问题:PHP ResultWrapper类的具体用法?PHP ResultWrapper怎么用?PHP ResultWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResultWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showContributions
/**
* Render the contributions of user to page
* @param ResultWrapper $res
*/
protected function showContributions(ResultWrapper $res)
{
$numRows = $res->numRows();
$rev = null;
$out = $this->getOutput();
$revs = array();
$prevRevs = array();
foreach ($res as $row) {
$rev = new Revision($row);
$revs[] = $rev;
if ($res->key() <= self::LIMIT + 1 && $rev->getParentId()) {
$prevRevs[] = $rev->getParentId();
}
}
$this->prevLengths = Revision::getParentLengths(wfGetDB(DB_SLAVE), $prevRevs);
if ($numRows > 0) {
$count = 0;
foreach ($revs as $rev) {
if ($count++ < self::LIMIT) {
$this->showContributionsRow($rev);
}
}
$out->addHtml('</ul>');
// Captured 1 more than we should have done so if the number of
// results is greater than the limit there are more to show.
if ($numRows > self::LIMIT) {
$out->addHtml($this->getMoreButton($rev->getTimestamp()));
}
} else {
// For users who exist but have not made any edits
$out->addHtml(MobileUI::warningBox($this->msg('mobile-frontend-history-no-results')));
}
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:37,代码来源:SpecialMobileContributions.php
示例2: materializeList
/**
* @param ResultWrapper $queryResult
* @return GWTUser[]
*/
private function materializeList($queryResult)
{
$list = array();
while ($obj = $queryResult->fetchObject()) {
$list[] = $this->materialize($obj);
}
return $list;
}
示例3: preprocessResults
/**
* Pre-fill the link cache
*
* @param DatabaseBase $db
* @param ResultWrapper $res
*/
function preprocessResults($db, $res)
{
if ($res->numRows() > 0) {
$linkBatch = new LinkBatch();
foreach ($res as $row) {
$linkBatch->add($row->namespace, $row->title);
}
$res->seek(0);
$linkBatch->execute();
}
}
示例4: preprocessResults
/**
* Run a LinkBatch to pre-cache LinkCache information,
* like page existence and information for stub color and redirect hints.
* This should be done for live data and cached data.
*
* @param IDatabase $db
* @param ResultWrapper $res
*/
public function preprocessResults($db, $res)
{
if (!$res->numRows()) {
return;
}
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add($row->namespace, $row->title);
}
$batch->execute();
$res->seek(0);
}
示例5: preprocessResults
/**
* Fetch user page links and cache their existence
*
* @param IDatabase $db
* @param ResultWrapper $res
*/
function preprocessResults($db, $res)
{
if (!$res->numRows()) {
return;
}
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add(NS_CATEGORY, $row->title);
}
$batch->execute();
// Back to start for display
$res->seek(0);
}
示例6: preprocessResults
/**
* @param IDatabase $db
* @param ResultWrapper $res
*/
function preprocessResults($db, $res)
{
# There's no point doing a batch check if we aren't caching results;
# the page must exist for it to have been pulled out of the table
if (!$this->isCached() || !$res->numRows()) {
return;
}
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add($row->namespace, $row->title);
}
$batch->execute();
$res->seek(0);
}
示例7: preprocessResults
/**
* Cache page existence for performance
*
* @param DatabaseBase $db
* @param ResultWrapper $res
*/
function preprocessResults($db, $res)
{
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add($row->namespace, $row->title);
$batch->addObj($this->getRedirectTarget($row));
}
$batch->execute();
// Back to start for display
if ($res->numRows() > 0) {
// If there are no rows we get an error seeking.
$db->dataSeek($res, 0);
}
}
示例8: preprocessResults
/**
* Cache page existence for performance
*
* @param IDatabase $db
* @param ResultWrapper $res
*/
function preprocessResults($db, $res)
{
if (!$res->numRows()) {
return;
}
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add($row->namespace, $row->title);
$batch->addObj($this->getRedirectTarget($row));
}
$batch->execute();
// Back to start for display
$res->seek(0);
}
示例9: loadFromRows
protected function loadFromRows(ResultWrapper $res)
{
$ret = array();
while ($row = $res->fetchObject()) {
unset($grp);
unset($ver);
// experiment
$e_id = $row->e_id;
if (!isset($ret[$e_id])) {
$ret[$e_id] = array('id' => $row->e_id, 'name' => $row->e_name, 'description' => $row->e_description, 'versions' => array(), 'groups' => array());
}
$exp =& $ret[$e_id];
// group
$g_id = $row->g_id;
if ($g_id && !isset($exp['groups'][$g_id])) {
$exp['groups'][$g_id] = array('experiment_id' => $e_id, 'id' => $row->g_id, 'name' => $row->g_name, 'description' => $row->g_description);
}
if ($g_id) {
$grp =& $exp['groups'][$g_id];
}
// version
$v_id = $row->v_id;
if ($v_id && !isset($exp['versions'][$v_id])) {
$exp['versions'][$v_id] = array('experiment_id' => $e_id, 'id' => $row->v_id, 'start_time' => $row->v_start_time, 'end_time' => $row->v_end_time, 'ga_slot' => $row->v_ga_slot, 'control_group_id' => $row->v_control_group_id, 'group_ranges' => array());
}
if ($v_id) {
$ver =& $exp['versions'][$v_id];
}
// group ranges
if ($g_id && $v_id && $row->r_group_id) {
// row in group_ranges found
if (!isset($ver['group_ranges'][$g_id])) {
$ver['group_ranges'][$g_id] = array('version_id' => $v_id, 'group_id' => $g_id, 'ranges' => $row->r_ranges);
}
}
}
return $ret;
}
示例10: showHistory
/**
* Render the history list
* @see showRow()
* @see doQuery()
* @param ResultWrapper $res The result of doQuery
*/
protected function showHistory(ResultWrapper $res)
{
$numRows = $res->numRows();
$rev1 = $rev2 = null;
$out = $this->getOutput();
if ($numRows > 0) {
foreach ($res as $row) {
$rev1 = new Revision($row);
if ($rev2) {
$this->showRow($rev2, $rev1);
}
$rev2 = $rev1;
}
if ($rev1 && $numRows < self::LIMIT + 1) {
$this->showRow($rev1, null);
}
$out->addHtml('</ul>');
// Captured 1 more than we should have done so if the number of
// results is greater than the limit there are more to show.
if ($numRows > self::LIMIT) {
$out->addHtml($this->getMoreButton($rev1->getTimestamp()));
}
} else {
// Edge case.
// I suspect this is here because revisions may exist but may have been hidden.
$out->addHtml(MobileUI::warningBox($this->msg('mobile-frontend-history-no-results')));
}
}
示例11: partitionResult
/**
* Partition a DB result with backlinks in it into batches
* @param ResultWrapper $res Database result
* @param int $batchSize
* @param bool $isComplete Whether $res includes all the backlinks
* @throws MWException
* @return array
*/
protected function partitionResult($res, $batchSize, $isComplete = true)
{
$batches = array();
$numRows = $res->numRows();
$numBatches = ceil($numRows / $batchSize);
for ($i = 0; $i < $numBatches; $i++) {
if ($i == 0 && $isComplete) {
$start = false;
} else {
$rowNum = $i * $batchSize;
$res->seek($rowNum);
$row = $res->fetchObject();
$start = (int) $row->page_id;
}
if ($i == $numBatches - 1 && $isComplete) {
$end = false;
} else {
$rowNum = min($numRows - 1, ($i + 1) * $batchSize - 1);
$res->seek($rowNum);
$row = $res->fetchObject();
$end = (int) $row->page_id;
}
# Sanity check order
if ($start && $end && $start > $end) {
throw new MWException(__METHOD__ . ': Internal error: query result out of order');
}
$batches[] = array($start, $end);
}
return array('numRows' => $numRows, 'batches' => $batches);
}
示例12: mysqlDataSeek
/**
* @param resource|ResultWrapper $res
* @param int $row
* @return mixed
*/
protected function mysqlDataSeek($res, $row)
{
return $res->data_seek($row);
}
示例13: combineResult
/**
* Combine results from 2 tables.
*
* Note: This will throw away some results
*
* @param ResultWrapper $res1
* @param ResultWrapper $res2
* @param int $limit
* @param bool $ascending See note about $asc in $this->reallyDoQuery
* @return FakeResultWrapper $res1 and $res2 combined
*/
protected function combineResult($res1, $res2, $limit, $ascending)
{
$res1->rewind();
$res2->rewind();
$topRes1 = $res1->next();
$topRes2 = $res2->next();
$resultArray = array();
for ($i = 0; $i < $limit && $topRes1 && $topRes2; $i++) {
if (strcmp($topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField}) > 0) {
if (!$ascending) {
$resultArray[] = $topRes1;
$topRes1 = $res1->next();
} else {
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
}
} else {
if (!$ascending) {
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
} else {
$resultArray[] = $topRes1;
$topRes1 = $res1->next();
}
}
}
// @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for (; $i < $limit && $topRes1; $i++) {
// @codingStandardsIgnoreEnd
$resultArray[] = $topRes1;
$topRes1 = $res1->next();
}
// @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for (; $i < $limit && $topRes2; $i++) {
// @codingStandardsIgnoreEnd
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
}
return new FakeResultWrapper($resultArray);
}
示例14: invalidateIDs
/**
* Invalidate a set of IDs, right now
*/
public function invalidateIDs(ResultWrapper $res)
{
global $wgUseFileCache, $wgUseSquid;
if ($res->numRows() == 0) {
return;
}
// sanity check
$dbw = wfGetDB(DB_MASTER);
$timestamp = $dbw->timestamp();
$done = false;
while (!$done) {
# Get all IDs in this query into an array
$ids = array();
for ($i = 0; $i < $this->mRowsPerQuery; $i++) {
$row = $res->fetchRow();
if ($row) {
$ids[] = $row[0];
} else {
$done = true;
break;
}
}
if (count($ids) == 0) {
break;
}
# Update page_touched
$dbw->update('page', array('page_touched' => $timestamp), array('page_id' => $ids), __METHOD__);
# Update static caches
if ($wgUseSquid || $wgUseFileCache) {
$titles = Title::newFromIDs($ids);
# Update squid cache
if ($wgUseSquid) {
$u = SquidUpdate::newFromTitles($titles);
$u->doUpdate();
}
# Update file cache
if ($wgUseFileCache) {
foreach ($titles as $title) {
HTMLFileCache::clearFileCache($title);
}
}
}
}
}
示例15: showList
/**
* Generic list of deleted pages
*
* @param ResultWrapper $result
* @return bool
*/
private function showList($result)
{
$out = $this->getOutput();
if ($result->numRows() == 0) {
$out->addWikiMsg('undelete-no-results');
return false;
}
$out->addWikiMsg('undeletepagetext', $this->getLanguage()->formatNum($result->numRows()));
$undelete = $this->getPageTitle();
$out->addHTML("<ul>\n");
foreach ($result as $row) {
$title = Title::makeTitleSafe($row->ar_namespace, $row->ar_title);
if ($title !== null) {
$item = Linker::linkKnown($undelete, htmlspecialchars($title->getPrefixedText()), array(), array('target' => $title->getPrefixedText()));
} else {
// The title is no longer valid, show as text
$item = Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->ar_namespace, $row->ar_title));
}
$revs = $this->msg('undeleterevisions')->numParams($row->count)->parse();
$out->addHTML("<li>{$item} ({$revs})</li>\n");
}
$result->free();
$out->addHTML("</ul>\n");
return true;
}