* @return SearchEngine
*/
public static function create() {
- global $wgDBtype, $wgSearchType;
+ global $wgSearchType;
+ $dbr = wfGetDB( DB_SLAVE );
if( $wgSearchType ) {
$class = $wgSearchType;
- } elseif( $wgDBtype == 'mysql' ) {
- $class = 'SearchMySQL';
- } else if ( $wgDBtype == 'postgres' ) {
- $class = 'SearchPostgres';
- } else if ( $wgDBtype == 'oracle' ) {
- $class = 'SearchOracle';
} else {
- $class = 'SearchEngineDummy';
+ $class = $dbr->getSearchEngine();
}
- $search = new $class( wfGetDB( DB_SLAVE ) );
+ $search = new $class( $dbr );
$search->setLimitOffset(0,0);
return $search;
}
$result = $this->query( "SELECT RELEASE_LOCK($lockName)", $method );
$this->freeResult( $result );
}
+
+ /**
+ * Get search engine class. All subclasses of this
+ * need to implement this if they wish to use searching.
+ *
+ * @return string
+ */
+ public function getSearchEngine() {
+ return "SearchMySQL";
+ }
}
/**
public function unlock( $lockName, $method ) {
return true;
}
+
+ public function getSearchEngine() {
+ return "SearchPostgres";
+ }
} // end DatabasePostgres class