mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 11:26:37 -04:00
Replace PHP filtering with pure SQL (#323)
* Replace PHP filtering with pure SQL
This commit is contained in:
parent
67fcdedd08
commit
d8360b28ca
2 changed files with 25 additions and 43 deletions
|
@ -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
|
||||
// ***********
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue