summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2006-07-31 08:50:34 +0100
committerAndrew Dolgov <[email protected]>2006-07-31 08:50:34 +0100
commite20c9d88c057d28e4e80e85f810adc79943e2dcd (patch)
tree1baa2d7b2ba3fa097e2b79984bc5d272f35d5198
parent57bce3cdbcf009588a05ea3d39bfcfd4ec88e721 (diff)
improved keyword search
-rw-r--r--functions.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/functions.php b/functions.php
index 4b118f4b5..686cecfeb 100644
--- a/functions.php
+++ b/functions.php
@@ -1931,14 +1931,34 @@
function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on) {
if ($search) {
+
+ $keywords = split(" ", $search);
+ $query_keywords = array();
+
if ($match_on == "both") {
- $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%')
- OR upper(ttrss_entries.content) LIKE '%$search%') AND";
+
+ foreach ($keywords as $k) {
+ array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%')
+ OR UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
+ }
+
+ $search_query_part = implode("AND", $query_keywords) . "AND";
+
} else if ($match_on == "title") {
- $search_query_part = "upper(ttrss_entries.title) LIKE upper('%$search%')
- AND";
+
+ foreach ($keywords as $k) {
+ array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%'))");
+ }
+
+ $search_query_part = implode("AND", $query_keywords) . "AND";
+
} else if ($match_on == "content") {
- $search_query_part = "upper(ttrss_entries.content) LIKE upper('%$search%') AND";
+
+ foreach ($keywords as $k) {
+ array_push($query_keywords, "(UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
+ }
+
+ $search_query_part = implode("AND", $query_keywords) . "AND";
}
} else {
$search_query_part = "";