aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAOSQLite.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/EntryDAOSQLite.php')
-rw-r--r--app/Models/EntryDAOSQLite.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index 9c2b37623..6d604f25a 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -28,6 +28,27 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
return str_replace('INSERT INTO ', 'INSERT OR IGNORE INTO ', $sql);
}
+ #[\Override]
+ protected static function sqlRegex(string $expression, string $regex, array &$values): string {
+ $values[] = $regex;
+ return "{$expression} REGEXP ?";
+ }
+
+ #[\Override]
+ protected function registerSqlFunctions(string $sql): void {
+ if (!str_contains($sql, ' REGEXP ')) {
+ return;
+ }
+ // https://php.net/pdo.sqlitecreatefunction
+ // https://www.sqlite.org/lang_expr.html#the_like_glob_regexp_match_and_extract_operators
+ $this->pdo->sqliteCreateFunction('regexp',
+ function (string $pattern, string $text): bool {
+ return preg_match($pattern, $text) === 1;
+ },
+ 2
+ );
+ }
+
/** @param array<string|int> $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {