MediaWiki  1.30.0
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 
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 }
SqlSearchResultSet\free
free()
Frees the result set, if applicable.
Definition: SqlSearchResultSet.php:53
SqlSearchResultSet\$totalHits
$totalHits
Definition: SqlSearchResultSet.php:12
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
php
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:35
SqlSearchResultSet\$resultSet
$resultSet
Definition: SqlSearchResultSet.php:10
SqlSearchResultSet\rewind
rewind()
Rewind result set back to beginning.
Definition: SqlSearchResultSet.php:47
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:529
SearchResultSet
Definition: SearchResultSet.php:27
SqlSearchResultSet\__construct
__construct(ResultWrapper $resultSet, $terms, $total=null)
Definition: SqlSearchResultSet.php:14
SqlSearchResultSet
This class is used for different SQL-based search engines shipped with MediaWiki.
Definition: SqlSearchResultSet.php:9
terms
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when you must cause when started running for such interactive use in the most ordinary to print or display an announcement including an appropriate copyright notice and a notice that there is no and telling the user how to view a copy of this and can be reasonably considered independent and separate works in then this and its terms
Definition: COPYING.txt:117
SqlSearchResultSet\termMatches
termMatches()
Fetch an array of regular expression fragments for matching the search terms as parsed by this engine...
Definition: SqlSearchResultSet.php:20
SqlSearchResultSet\numRows
numRows()
Definition: SqlSearchResultSet.php:24
SearchResult\newFromTitle
static newFromTitle( $title, SearchResultSet $parentSet=null)
Return a new SearchResult and initializes it with a title.
Definition: SearchResult.php:72
SqlSearchResultSet\next
next()
Fetches next search result, or false.
Definition: SqlSearchResultSet.php:32
SqlSearchResultSet\$terms
$terms
Definition: SqlSearchResultSet.php:11
SqlSearchResultSet\getTotalHits
getTotalHits()
Some search modes return a total hit count for the query in the entire article database.
Definition: SqlSearchResultSet.php:61