MediaWiki REL1_28
SqlSearchResultSet.php
Go to the documentation of this file.
1<?php
7 protected $resultSet;
8 protected $terms;
9 protected $totalHits;
10
11 function __construct( ResultWrapper $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
40 Title::makeTitle( $row->page_namespace, $row->page_title ), $this
41 );
42 }
43
44 function rewind() {
45 if ( $this->resultSet ) {
46 $this->resultSet->rewind();
47 }
48 }
49
50 function free() {
51 if ( $this->resultSet === false ) {
52 return false;
53 }
54
55 $this->resultSet->free();
56 }
57
58 function getTotalHits() {
59 if ( !is_null( $this->totalHits ) ) {
60 return $this->totalHits;
61 } else {
62 // Special:Search expects a number here.
63 return $this->numRows();
64 }
65 }
66}
Result wrapper for grabbing data queried from an IDatabase object.
static newFromTitle( $title, SearchResultSet $parentSet=null)
Return a new SearchResult and initializes it with a title.
This class is used for different SQL-based search engines shipped with MediaWiki.
free()
Frees the result set, if applicable.
getTotalHits()
Some search modes return a total hit count for the query in the entire article database.
termMatches()
Fetch an array of regular expression fragments for matching the search terms as parsed by this engine...
next()
Fetches next search result, or false.
rewind()
Rewind result set back to beginning.
__construct(ResultWrapper $resultSet, $terms, $total=null)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37