]> git.wh0rd.org Git - tt-rss.git/commitdiff
improved keyword search
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 31 Jul 2006 07:50:34 +0000 (08:50 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 31 Jul 2006 07:50:34 +0000 (08:50 +0100)
functions.php

index 4b118f4b597598169e631f5f26178c0ae8915179..686cecfeb1422b2a7e8ef285e45ef8e5432a7c8c 100644 (file)
        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 = "";