return 0;
}
- /**
- * Return true if results are included in this result set.
- * STUB
- *
- * @return bool
- */
- function hasResults() {
- return false;
- }
-
/**
* Some search modes return a total hit count for the query
* in the entire article database. This may include pages
* @ingroup Search
*/
class SqlSearchResultSet extends SearchResultSet {
+ protected $resultSet;
+ protected $terms;
+ protected $totalHits;
- protected $mResultSet;
-
- function __construct( $resultSet, $terms ) {
- $this->mResultSet = $resultSet;
- $this->mTerms = $terms;
+ function __construct( $resultSet, $terms, $total = null ) {
+ $this->resultSet = $resultSet;
+ $this->terms = $terms;
+ $this->totalHits = $total;
}
function termMatches() {
- return $this->mTerms;
+ return $this->terms;
}
function numRows() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- return $this->mResultSet->numRows();
+ return $this->resultSet->numRows();
}
function next() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- $row = $this->mResultSet->fetchObject();
+ $row = $this->resultSet->fetchObject();
if ( $row === false ) {
return false;
}
}
function free() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- $this->mResultSet->free();
+ $this->resultSet->free();
+ }
+
+ function getTotalHits() {
+ if ( !is_null( $this->totalHits ) ) {
+ return $this->totalHits;
+ } else {
+ // Special:Search expects a number here.
+ return $this->numRows();
+ }
}
}
$this->result = $match;
}
- public function hasResult() {
- return (bool)$this->result;
- }
-
public function numRows() {
- return $this->hasResults() ? 1 : 0;
+ return $this->result ? 1 : 0;
}
public function next() {