From 69ca13fa508f0e9ea80869106e0c529368ad6d9c Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 7 Jul 2007 02:52:33 +0000 Subject: [PATCH] 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 --- core/database.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/database.class.php b/core/database.class.php index b305f0f3..100708a6 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -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)); } } // }}}