本文整理汇总了PHP中ResultWrapper::seek方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultWrapper::seek方法的具体用法?PHP ResultWrapper::seek怎么用?PHP ResultWrapper::seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultWrapper
的用法示例。
在下文中一共展示了ResultWrapper::seek方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: extractResultInfo
/**
* Extract some useful data from the result object for use by
* the navigation bar, put it into $this
*/
function extractResultInfo($offset, $limit, ResultWrapper $res)
{
$numRows = $res->numRows();
if ($numRows) {
$row = $res->fetchRow();
$firstIndex = $row[$this->mIndexField];
# Discard the extra result row if there is one
if ($numRows > $this->mLimit && $numRows > 1) {
$res->seek($numRows - 1);
$this->mPastTheEndRow = $res->fetchObject();
$indexField = $this->mIndexField;
$this->mPastTheEndIndex = $this->mPastTheEndRow->{$indexField};
$res->seek($numRows - 2);
$row = $res->fetchRow();
$lastIndex = $row[$this->mIndexField];
} else {
$this->mPastTheEndRow = null;
# Setting indexes to an empty string means that they will be
# omitted if they would otherwise appear in URLs. It just so
# happens that this is the right thing to do in the standard
# UI, in all the relevant cases.
$this->mPastTheEndIndex = '';
$res->seek($numRows - 1);
$row = $res->fetchRow();
$lastIndex = $row[$this->mIndexField];
}
} else {
$firstIndex = '';
$lastIndex = '';
$this->mPastTheEndRow = null;
$this->mPastTheEndIndex = '';
}
if ($this->mIsBackwards) {
$this->mIsFirst = $numRows < $limit;
$this->mIsLast = $offset == '';
$this->mLastShown = $firstIndex;
$this->mFirstShown = $lastIndex;
} else {
$this->mIsFirst = $offset == '';
$this->mIsLast = $numRows < $limit;
$this->mLastShown = $lastIndex;
$this->mFirstShown = $firstIndex;
}
}
示例7: getBody
/**
* Get the formatted result list. Calls getStartBody(), formatRow() and
* getEndBody(), concatenates the results and returns them.
*
* @return String
*/
public function getBody() {
if ( !$this->mQueryDone ) {
$this->doQuery();
}
if ( $this->mResult->numRows() ) {
# Do any special query batches before display
$this->doBatchLookups();
}
# Don't use any extra rows returned by the query
$numRows = min( $this->mResult->numRows(), $this->mLimit );
$s = $this->getStartBody();
if ( $numRows ) {
if ( $this->mIsBackwards ) {
for ( $i = $numRows - 1; $i >= 0; $i-- ) {
$this->mResult->seek( $i );
$row = $this->mResult->fetchObject();
$s .= $this->formatRow( $row );
}
} else {
$this->mResult->seek( 0 );
for ( $i = 0; $i < $numRows; $i++ ) {
$row = $this->mResult->fetchObject();
$s .= $this->formatRow( $row );
}
}
} else {
$s .= $this->getEmptyBody();
}
$s .= $this->getEndBody();
return $s;
}
示例8: 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);
}
示例9: preprocessResults
/**
* Initialize total values so we can figure out percentages later.
*
* @param IDatabase $dbr
* @param ResultWrapper $res
*/
public function preprocessResults($dbr, $res)
{
$this->totalCount = $this->totalBytes = 0;
foreach ($res as $row) {
$mediaStats = $this->splitFakeTitle($row->title);
$this->totalCount += isset($mediaStats[2]) ? $mediaStats[2] : 0;
$this->totalBytes += isset($mediaStats[3]) ? $mediaStats[3] : 0;
}
$res->seek(0);
}
示例10: executeLBFromResultWrapper
/**
* Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include
* title and optional the namespace field) and executes the batch. This operation will pre-cache
* LinkCache information like page existence and information for stub color and redirect hints.
*
* @param ResultWrapper $res The ResultWrapper object to process. Needs to include the title
* field and namespace field, if the $ns parameter isn't set.
* @param null $ns Use this namespace for the given titles in the ResultWrapper object,
* instead of the namespace value of $res.
*/
protected function executeLBFromResultWrapper(ResultWrapper $res, $ns = null)
{
if (!$res->numRows()) {
return;
}
$batch = new LinkBatch();
foreach ($res as $row) {
$batch->add($ns !== null ? $ns : $row->namespace, $row->title);
}
$batch->execute();
$res->seek(0);
}
示例11: preprocessResults
/**
* Cache page content model and gender distinction 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);
if (isset($row->nsb)) {
// lazy loaded when using cached results
$batch->add($row->nsb, $row->tb);
}
if (isset($row->iwc) && !$row->iwc) {
// lazy loaded when using cached result, not added when interwiki link
$batch->add($row->nsc, $row->tc);
}
}
$batch->execute();
// Back to start for display
$res->seek(0);
}