+ protected function buildQueryInfo( $offset, $limit, $descending ) {
+ $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
+
+ $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
+ if ( $descending ) {
+ $orderBy = $sortColumns;
+ $operator = $this->mIncludeOffset ? '>=' : '>';
+ } else {
+ $orderBy = [];
+ foreach ( $sortColumns as $col ) {
+ $orderBy[] = $col . ' DESC';
+ }
+ $operator = $this->mIncludeOffset ? '<=' : '<';
+ }
+ $info = $this->getQueryInfo( [
+ 'limit' => intval( $limit ),
+ 'order' => $descending ? 'DESC' : 'ASC',
+ 'conds' =>
+ $offset != '' ? [ $this->mIndexField . $operator . $this->mDb->addQuotes( $offset ) ] : [],
+ ] );
+
+ $tables = $info['tables'];
+ $fields = $info['fields'];
+ $conds = $info['conds'];
+ $options = $info['options'];
+ $join_conds = $info['join_conds'];
+ $options['ORDER BY'] = $orderBy;
+ return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
+ }
+