update tag counts on set_tags / delete_tags_from_image
git-svn-id: file:///home/shish/svn/shimmie2/trunk@239 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
fa49bf13f3
commit
69ca13fa50
1 changed files with 3 additions and 1 deletions
|
@ -212,6 +212,7 @@ class Database {
|
|||
}
|
||||
|
||||
public function delete_tags_from_image($image_id) {
|
||||
$this->execute("UPDATE tags SET count = count - 1 WHERE id IN (SELECT tag_id FROM image_tags WHERE image_id = ?)", array($image_id));
|
||||
$this->execute("DELETE FROM image_tags WHERE image_id=?", array($image_id));
|
||||
}
|
||||
|
||||
|
@ -227,8 +228,9 @@ class Database {
|
|||
|
||||
// insert each new tag
|
||||
foreach($tags as $tag) {
|
||||
$this->execute("INSERT IGNORE INTO tags(tag) VALUES (?)", array($tag));
|
||||
$this->execute("INSERT IGNORE INTO tags(tag) VALUES (?)", array($tag));
|
||||
$this->execute("INSERT INTO image_tags(image_id, tag_id) VALUES(?, (SELECT id FROM tags WHERE tag = ?))", array($image_id, $tag));
|
||||
$this->execute("UPDATE tags SET count = count + 1 WHERE tag = ?", array($tag));
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
|
Reference in a new issue