From f0168d61604db800f59c24ba26bfda717270c71f Mon Sep 17 00:00:00 2001 From: shish Date: Fri, 6 Jul 2007 07:28:42 +0000 Subject: [PATCH] wildcard searches. This may be faster, as the big query uses IDs rather than tags? needs testing~ git-svn-id: file:///home/shish/svn/shimmie2/trunk@235 7f39781d-f577-437e-ae19-be835c7a54ca --- core/database.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/database.class.php b/core/database.class.php index f527e208..b305f0f3 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -178,13 +178,19 @@ class Database { else { $s_tag_array = array_map("sql_escape", $tag_search->variables); $s_tag_list = join(', ', $s_tag_array); + + $tag_id_array = array(); + foreach($tag_search->variables as $tag) { + $tag_id_array = array_merge($tag_id_array, $this->db->GetCol("SELECT id FROM tags WHERE tag LIKE ?", array($tag))); + } + $tag_id_list = join(', ', $tag_id_array); $subquery = new Querylet(" SELECT images.*, SUM({$tag_search->sql}) AS score FROM images LEFT JOIN image_tags ON image_tags.image_id = images.id JOIN tags ON image_tags.tag_id = tags.id - WHERE tags.tag IN ({$s_tag_list}) + WHERE tags.id IN ({$tag_id_list}) GROUP BY images.id HAVING score = ?", array_merge(