From a090d45ce09d40fc9a0af1ae5c79e6b252acddca Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 28 Apr 2007 16:56:39 +0000 Subject: [PATCH] minor tweak to search SQL, huge speedup in several cases git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.0@26 7f39781d-f577-437e-ae19-be835c7a54ca --- core/database.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/database.class.php b/core/database.class.php index 89b3aec5..2c92ddd2 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -123,10 +123,14 @@ class Database { $query = new Querylet("SELECT * FROM images "); } else { + $s_tag_array = array_map("sql_escape", $tag_search->variables); + $s_tag_list = join(', ', $s_tag_array); + $subquery = new Querylet(" SELECT *, SUM({$tag_search->sql}) AS score FROM images LEFT JOIN tags ON tags.image_id = images.id + WHERE tags.tag IN ({$s_tag_list}) GROUP BY images.id HAVING score = ?", array_merge(