Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / search / SqlSearchResultSet.php
1 <?php
2 /**
3 * This class is used for different SQL-based search engines shipped with MediaWiki
4 * @ingroup Search
5 */
6 class SqlSearchResultSet extends SearchResultSet {
7 protected $resultSet;
8 protected $terms;
9 protected $totalHits;
10
11 function __construct( $resultSet, $terms, $total = null ) {
12 $this->resultSet = $resultSet;
13 $this->terms = $terms;
14 $this->totalHits = $total;
15 }
16
17 function termMatches() {
18 return $this->terms;
19 }
20
21 function numRows() {
22 if ( $this->resultSet === false ) {
23 return false;
24 }
25
26 return $this->resultSet->numRows();
27 }
28
29 function next() {
30 if ( $this->resultSet === false ) {
31 return false;
32 }
33
34 $row = $this->resultSet->fetchObject();
35 if ( $row === false ) {
36 return false;
37 }
38
39 return SearchResult::newFromTitle(
40 Title::makeTitle( $row->page_namespace, $row->page_title )
41 );
42 }
43
44 function free() {
45 if ( $this->resultSet === false ) {
46 return false;
47 }
48
49 $this->resultSet->free();
50 }
51
52 function getTotalHits() {
53 if ( !is_null( $this->totalHits ) ) {
54 return $this->totalHits;
55 } else {
56 // Special:Search expects a number here.
57 return $this->numRows();
58 }
59 }
60 }