MediaWiki REL1_31
SearchDatabase.php
Go to the documentation of this file.
1<?php
25
35 protected $db;
36
40 public function __construct( IDatabase $db = null ) {
41 if ( $db ) {
42 $this->db = $db;
43 } else {
44 $this->db = wfGetDB( DB_REPLICA );
45 }
46 }
47
54 protected function filter( $text ) {
55 // List of chars allowed in the search query.
56 // This must include chars used in the search syntax.
57 // Usually " (phrase) or * (wildcards) if supported by the engine
58 $lc = $this->legalSearchChars( self::CHARS_ALL );
59 return trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
60 }
61}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Base search engine base class for database-backed searches.
__construct(IDatabase $db=null)
filter( $text)
Return a 'cleaned up' search string.
IDatabase $db
Slave database for reading from for results.
Contain a class for special pages.
static legalSearchChars( $type=self::CHARS_ALL)
Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
const DB_REPLICA
Definition defines.php:25