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
This commit is contained in:
parent
a46fcb8463
commit
f0168d6160
1 changed files with 7 additions and 1 deletions
|
@ -178,13 +178,19 @@ class Database {
|
||||||
else {
|
else {
|
||||||
$s_tag_array = array_map("sql_escape", $tag_search->variables);
|
$s_tag_array = array_map("sql_escape", $tag_search->variables);
|
||||||
$s_tag_list = join(', ', $s_tag_array);
|
$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("
|
$subquery = new Querylet("
|
||||||
SELECT images.*, SUM({$tag_search->sql}) AS score
|
SELECT images.*, SUM({$tag_search->sql}) AS score
|
||||||
FROM images
|
FROM images
|
||||||
LEFT JOIN image_tags ON image_tags.image_id = images.id
|
LEFT JOIN image_tags ON image_tags.image_id = images.id
|
||||||
JOIN tags ON image_tags.tag_id = tags.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
|
GROUP BY images.id
|
||||||
HAVING score = ?",
|
HAVING score = ?",
|
||||||
array_merge(
|
array_merge(
|
||||||
|
|
Reference in a new issue