* @ingroup Pager
*/
+use Wikimedia\Rdbms\IResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
/**
* IndexPager is an efficient pager which uses a (roughly unique) index in the
* data set to implement paging, rather than a "LIMIT offset,limit" clause.
/**
* Result object for the query. Warning: seek before use.
*
- * @var ResultWrapper
+ * @var IResultWrapper
*/
public $mResult;
: [];
} elseif ( is_array( $index ) ) {
# First element is the default
- reset( $index );
- list( $this->mOrderType, $this->mIndexField ) = each( $index );
+ $this->mIndexField = reset( $index );
+ $this->mOrderType = key( $index );
$this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
? (array)$extraSort[$this->mOrderType]
: [];
*/
public function doQuery() {
# Use the child class name for profiling
- $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
+ $fname = __METHOD__ . ' (' . static::class . ')';
$section = Profiler::instance()->scopedProfileIn( $fname );
// @todo This should probably compare to DIR_DESCENDING and DIR_ASCENDING constants
}
/**
- * @return ResultWrapper The result wrapper.
+ * @return IResultWrapper The result wrapper.
*/
function getResult() {
return $this->mResult;
* @param bool $isFirst False if there are rows before those fetched (i.e.
* if a "previous" link would make sense)
* @param int $limit Exact query limit
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
- function extractResultInfo( $isFirst, $limit, ResultWrapper $res ) {
+ function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
$numRows = $res->numRows();
if ( $numRows ) {
# Remove any table prefix from index field
* @return string
*/
function getSqlComment() {
- return get_class( $this );
+ return static::class;
}
/**
* @param string $offset Index offset, inclusive
* @param int $limit Exact query limit
* @param bool $descending Query direction, false for ascending, true for descending
- * @return ResultWrapper
+ * @return IResultWrapper
*/
public function reallyDoQuery( $offset, $limit, $descending ) {
list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
/**
* Pre-process results; useful for performing batch existence checks, etc.
*
- * @param ResultWrapper $result
+ * @param IResultWrapper $result
*/
protected function preprocessResults( $result ) {
}
* @return bool
*/
protected function getDefaultDirections() {
- return IndexPager::DIR_ASCENDING;
+ return self::DIR_ASCENDING;
}
}