if a tag has no matches, error

git-svn-id: file:///home/shish/svn/shimmie2/trunk@354 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-07-23 00:52:24 +00:00
parent f948ae8720
commit bcc9b612c1

View file

@ -171,9 +171,14 @@ class Database {
$s_tag_list = join(', ', $s_tag_array);
$tag_id_array = array();
$tags_ok = true;
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_ids = $this->db->GetCol("SELECT id FROM tags WHERE tag LIKE ?", array($tag));
$tag_id_array = array_merge($tag_id_array, $tag_ids);
$tags_ok = count($tag_ids) > 0;
if(!$tags_ok) break;
}
if($tags_ok) {
$tag_id_list = join(', ', $tag_id_array);
$subquery = new Querylet("
@ -192,6 +197,17 @@ class Database {
$query = new Querylet("
SELECT *, UNIX_TIMESTAMP(posted) AS posted_timestamp
FROM ({$subquery->sql}) AS images ", $subquery->variables);
}
else {
# there are no results, "where 1=0" should shortcut things
$query = new Querylet("
SELECT images.*
FROM images
LEFT JOIN image_tags ON image_tags.image_id = images.id
JOIN tags ON image_tags.tag_id = tags.id
WHERE 1=0
");
}
if(strlen($img_search->sql) > 0) {
$query->append_sql("WHERE 1=1 ");