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
@ -212,6 +212,7 @@ class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function delete_tags_from_image($image_id) {
|
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));
|
$this->execute("DELETE FROM image_tags WHERE image_id=?", array($image_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +230,7 @@ class Database {
|
|||||||
foreach($tags as $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("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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user