MediaWiki REL1_31
SqlSearchResultSet.php
Go to the documentation of this file.
1<?php
2
4
10 protected $resultSet;
11 protected $terms;
12 protected $totalHits;
13
14 function __construct( ResultWrapper $resultSet, $terms, $total = null ) {
15 $this->resultSet = $resultSet;
16 $this->terms = $terms;
17 $this->totalHits = $total;
18 }
19
20 function termMatches() {
21 return $this->terms;
22 }
23
24 function numRows() {
25 if ( $this->resultSet === false ) {
26 return false;
27 }
28
29 return $this->resultSet->numRows();
30 }
31
32 function next() {
33 if ( $this->resultSet === false ) {
34 return false;
35 }
36
37 $row = $this->resultSet->fetchObject();
38 if ( $row === false ) {
39 return false;
40 }
41
42 return SearchResult::newFromTitle(
43 Title::makeTitle( $row->page_namespace, $row->page_title ), $this
44 );
45 }
46
47 function rewind() {
48 if ( $this->resultSet ) {
49 $this->resultSet->rewind();
50 }
51 }
52
53 function free() {
54 if ( $this->resultSet === false ) {
55 return false;
56 }
57
58 $this->resultSet->free();
59 }
60
61 function getTotalHits() {
62 if ( !is_null( $this->totalHits ) ) {
63 return $this->totalHits;
64 } else {
65 // Special:Search expects a number here.
66 return $this->numRows();
67 }
68 }
69}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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)
Result wrapper for grabbing data queried from an IDatabase object.
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