本文整理汇总了PHP中ResultWrapper::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultWrapper::rewind方法的具体用法?PHP ResultWrapper::rewind怎么用?PHP ResultWrapper::rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultWrapper
的用法示例。
在下文中一共展示了ResultWrapper::rewind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset
/**
* Start iteration. This must be called before current() or next().
* @return Revision First list item
*/
public function reset()
{
if (!$this->res) {
$this->res = $this->doQuery(wfGetDB(DB_SLAVE));
} else {
$this->res->rewind();
}
$this->initCurrent();
return $this->current;
}
示例2: doQuery
/**
* Do the query, using information from the object context. This function
* has been kept minimal to make it overridable if necessary, to allow for
* result sets formed from multiple DB queries.
*/
public function doQuery() {
# Use the child class name for profiling
$fname = __METHOD__ . ' (' . get_class( $this ) . ')';
wfProfileIn( $fname );
$descending = ( $this->mIsBackwards == $this->mDefaultDirection );
# Plus an extra row so that we can tell the "next" link should be shown
$queryLimit = $this->mLimit + 1;
if ( $this->mOffset == '' ) {
$isFirst = true;
} else {
// If there's an offset, we may or may not be at the first entry.
// The only way to tell is to run the query in the opposite
// direction see if we get a row.
$oldIncludeOffset = $this->mIncludeOffset;
$this->mIncludeOffset = !$this->mIncludeOffset;
$isFirst = !$this->reallyDoQuery( $this->mOffset, 1, !$descending )->numRows();
$this->mIncludeOffset = $oldIncludeOffset;
}
$this->mResult = $this->reallyDoQuery(
$this->mOffset,
$queryLimit,
$descending
);
$this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
$this->mQueryDone = true;
$this->preprocessResults( $this->mResult );
$this->mResult->rewind(); // Paranoia
wfProfileOut( $fname );
}
示例3: 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);
}
示例4: doQuery
/**
* Do the query, using information from the object context. This function
* has been kept minimal to make it overridable if necessary, to allow for
* result sets formed from multiple DB queries.
*/
public function doQuery()
{
# Use the child class name for profiling
$fname = __METHOD__ . ' (' . get_class($this) . ')';
wfProfileIn($fname);
$descending = $this->mIsBackwards == $this->mDefaultDirection;
# Plus an extra row so that we can tell the "next" link should be shown
$queryLimit = $this->mLimit + 1;
$this->mResult = $this->reallyDoQuery($this->mOffset, $queryLimit, $descending);
$this->extractResultInfo($this->mOffset, $queryLimit, $this->mResult);
$this->mQueryDone = true;
$this->preprocessResults($this->mResult);
$this->mResult->rewind();
// Paranoia
wfProfileOut($fname);
}
示例5: rewind
function rewind()
{
$this->res->rewind();
$this->key = 0;
$this->setCurrent($this->res->current());
}