* Adjust code

This commit is contained in:
zenggang
2022-04-06 06:07:46 +00:00
parent c149ac6299
commit 6cdf575678
+3 -3
View File
@@ -548,12 +548,12 @@ class searchModel extends model
$trimedWord = trim($splitedWords['words']);
$against .= '"' . $trimedWord . '" ';
$againstCond .= '+"' . $trimedWord . '" ';
if(is_numeric($word) and (strpos($word, '.') === false) and strlen($word) == 5) $againstCond .= "-\" $word \" ";
if(is_numeric($word) and strpos($word, '.') === false and strlen($word) == 5) $againstCond .= "-\" $word \" ";
$likeWord = is_numeric($word) ? $word : $trimedWord;
if(is_numeric($word) and (strpos($word, '.') === false) and strlen($word) < 5) $likeWord = str_pad("|$likeWord|", 5, '_');
if(is_numeric($word) and strpos($word, '.') === false and strlen($word) < 5) $likeWord = str_pad("|$likeWord|", 5, '_');
$condition = "OR title like '%{$likeWord}%' OR content like '%{$likeWord}%'";
if(is_numeric($word) and (strpos($word, '.') === false) and strlen($word) == 5) $condition = "OR title REGEXP '[^ ]{$likeWord}[^ ]' OR content REGEXP '[^ ]{$likeWord}[^ ]'";
if(is_numeric($word) and strpos($word, '.') === false and strlen($word) == 5) $condition = "OR title REGEXP '[^ ]{$likeWord}[^ ]' OR content REGEXP '[^ ]{$likeWord}[^ ]'";
$likeCondition .= $condition;
}