Replace PHP filtering with pure SQL (#323)

* Replace PHP filtering with pure SQL
This commit is contained in:
Mike Colagrosso 2024-01-21 13:08:46 -07:00 committed by GitHub
parent 67fcdedd08
commit d8360b28ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 43 deletions

View file

@ -834,31 +834,6 @@ class Artwork extends PropertiesBase{
', [$this->ArtworkId]);
}
public function Contains(string $query): bool{
$searchString = $this->Name;
$searchString .= ' ' . $this->Artist->Name;
$searchString .= ' ' . implode(' ', $this->Artist->AlternateNames);
foreach($this->Tags as $tag){
$searchString .= ' ' . $tag->Name;
}
// Remove diacritics and non-alphanumeric characters
$searchString = trim(preg_replace('|[^a-zA-Z0-9 ]|ius', ' ', Formatter::RemoveDiacritics($searchString)));
$query = trim(preg_replace('|[^a-zA-Z0-9 ]|ius', ' ', Formatter::RemoveDiacritics($query)));
if($query == ''){
return false;
}
if(mb_stripos($searchString, $query) !== false){
return true;
}
return false;
}
// ***********
// ORM METHODS
// ***********