mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX Fixed MSSQLDatabase::searchEngine() to search keywords properly by connecting them with AND to go in the CONTAINS() function
This commit is contained in:
parent
31cedd108b
commit
f5d41cedfd
@ -1092,9 +1092,25 @@ class MSSQLDatabase extends Database {
|
|||||||
*/
|
*/
|
||||||
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
|
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
|
||||||
if($this->fullTextEnabled) {
|
if($this->fullTextEnabled) {
|
||||||
$keywords = Convert::raw2sql(trim($keywords, ' *'));
|
$keywords = Convert::raw2sql(trim($keywords));
|
||||||
$htmlEntityKeywords = htmlentities($keywords);
|
$htmlEntityKeywords = htmlentities($keywords);
|
||||||
|
|
||||||
|
$keywordList = explode(' ', $keywords);
|
||||||
|
if($keywordList) {
|
||||||
|
foreach($keywordList as $index => $keyword) {
|
||||||
|
$keywordList[$index] = "\"{$keyword}\"";
|
||||||
|
}
|
||||||
|
$keywords = implode(' AND ', $keywordList);
|
||||||
|
}
|
||||||
|
|
||||||
|
$htmlEntityKeywordList = explode(' ', $htmlEntityKeywords);
|
||||||
|
if($htmlEntityKeywordList) {
|
||||||
|
foreach($htmlEntityKeywordList as $index => $keyword) {
|
||||||
|
$htmlEntityKeywordList[$index] = "\"{$keyword}\"";
|
||||||
|
}
|
||||||
|
$htmlEntityKeywords = implode(' AND ', $htmlEntityKeywordList);
|
||||||
|
}
|
||||||
|
|
||||||
//Get a list of all the tables and columns we'll be searching on:
|
//Get a list of all the tables and columns we'll be searching on:
|
||||||
$result=DB::query('EXEC sp_help_fulltext_columns');
|
$result=DB::query('EXEC sp_help_fulltext_columns');
|
||||||
if (!$result->numRecords()) throw Exception('there are no full text columns to search');
|
if (!$result->numRecords()) throw Exception('there are no full text columns to search');
|
||||||
|
Loading…
Reference in New Issue
Block a user