diff options
| author | 2025-12-20 11:06:39 +0100 | |
|---|---|---|
| committer | 2025-12-20 11:06:39 +0100 | |
| commit | af1e5cb9bc0c81e36a095b70073f0d23cf4554a9 (patch) | |
| tree | b9a584b47cb2eda3a46d4ae034086cf48632e0c5 /app/Models/DatabaseDAOPGSQL.php | |
| parent | f71636955fbb58546433d5b1593e1f977c051ea6 (diff) | |
More uniform SQL search and PHP search (#8329)
* More uniform SQL search and PHP search
The behaviour depends though on the database.
Improve https://github.com/FreshRSS/FreshRSS/discussions/8265#discussioncomment-15278980
* Try to use transliterator_transliterate function instead
Diffstat (limited to 'app/Models/DatabaseDAOPGSQL.php')
| -rw-r--r-- | app/Models/DatabaseDAOPGSQL.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index 3fa70cd88..116f8816e 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -99,4 +99,19 @@ SQL; } return $ok; } + + #[\Override] + public static function strilike(string $haystack, string $needle): bool { + if (function_exists('mb_stripos')) { + return mb_stripos($haystack, $needle, 0, 'UTF-8') !== false; + } + if (function_exists('transliterator_transliterate')) { + $haystack_ = transliterator_transliterate('Lower', $haystack); + $needle_ = transliterator_transliterate('Lower', $needle); + if ($haystack_ !== false && $needle_ !== false) { + return str_contains($haystack_, $needle_); + } + } + return stripos($haystack, $needle) !== false; + } } |
