summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-01-18 16:03:45 +0300
committerAndrew Dolgov <[email protected]>2010-01-18 16:03:45 +0300
commiteb6c7f4240b772314e99fd8e81ea90be3412d417 (patch)
tree5fa6fd776007b422c3882df066262224b3d54c1d /functions.php
parente15bb6f7dbed5252da5b93a2b6995dedbdca9d17 (diff)
getSearchSql: support excluding keywords with -
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/functions.php b/functions.php
index 398540dfa..c7bf4eaa3 100644
--- a/functions.php
+++ b/functions.php
@@ -3251,8 +3251,15 @@
if ($match_on == "both") {
foreach ($keywords as $k) {
- array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%')
- OR UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
+ if (strpos($k, "-") === 0) {
+ $k = substr($k, 1);
+ $not = "NOT";
+ } else {
+ $not = "";
+ }
+
+ array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
+ OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
}
$search_query_part = implode("AND", $query_keywords) . " AND ";
@@ -3260,7 +3267,14 @@
} else if ($match_on == "title") {
foreach ($keywords as $k) {
- array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%'))");
+ if (strpos($k, "-") === 0) {
+ $k = substr($k, 1);
+ $not = "NOT";
+ } else {
+ $not = "";
+ }
+
+ array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%'))");
}
$search_query_part = implode("AND", $query_keywords) . " AND ";
@@ -3268,7 +3282,14 @@
} else if ($match_on == "content") {
foreach ($keywords as $k) {
- array_push($query_keywords, "(UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
+ if (strpos($k, "-") === 0) {
+ $k = substr($k, 1);
+ $not = "NOT";
+ } else {
+ $not = "";
+ }
+
+ array_push($query_keywords, "(UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
}
}