From f12e0b8f60168f246aafd42136a175b06ac3f125 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 28 Apr 2007 18:58:23 +0000 Subject: [PATCH] one step towards faster searching git-svn-id: file:///home/shish/svn/shimmie2/trunk@29 7f39781d-f577-437e-ae19-be835c7a54ca --- core/database.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 253c10ce..aa8a6948 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -81,6 +81,7 @@ class Database { private function build_search_querylet($terms) { $tag_search = new Querylet("0"); $positive_tag_count = 0; + $negative_tag_count = 0; $img_search = new Querylet(""); foreach($terms as $term) { @@ -114,12 +115,12 @@ class Database { $term = str_replace("?", "_", $term); $sign = $negative ? "-" : "+"; if($sign == "+") $positive_tag_count++; + else $negative_tag_count++; $tag_search->append(new Querylet(" $sign (tag LIKE ?)", array($term))); } } - $database_fails = false; // MySQL 4.0 fails at subqueries - if(count($tag_search->variables) == 0 || $database_fails) { + if($positive_tag_count + $negative_tag_count == 0) { $query = new Querylet("SELECT * FROM images "); } else {