diff options
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-x | inc/poche/Database.class.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 02e8be8b..9e901974 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -512,22 +512,23 @@ class Database { | |||
512 | return $query; | 512 | return $query; |
513 | } | 513 | } |
514 | 514 | ||
515 | public function cleanUnusedTags() { | 515 | public function cleanUnusedTag($tag_id) { |
516 | $sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id"; | 516 | $sql_action = "SELECT tags.* FROM tags JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?"; |
517 | $query = $this->executeQuery($sql_action,array()); | 517 | $query = $this->executeQuery($sql_action,array($tag_id)); |
518 | $tagstokeep = $query->fetchAll(); | 518 | $tagstokeep = $query->fetchAll(); |
519 | $sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id"; | 519 | $sql_action = "SELECT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags.id=?"; |
520 | $query = $this->executeQuery($sql_action,array()); | 520 | $query = $this->executeQuery($sql_action,array($tag_id)); |
521 | $alltags = $query->fetchAll(); | 521 | $alltags = $query->fetchAll(); |
522 | |||
522 | foreach ($alltags as $tag) { | 523 | foreach ($alltags as $tag) { |
523 | if ($tag && !in_array($tag,$tagstokeep)) { | 524 | if ($tag && !in_array($tag,$tagstokeep)) { |
524 | //delete tag | ||
525 | $sql_action = "DELETE FROM tags WHERE id=?"; | 525 | $sql_action = "DELETE FROM tags WHERE id=?"; |
526 | $params_action = array($tag[0]); | 526 | $params_action = array($tag[0]); |
527 | $query = $this->executeQuery($sql_action, $params_action); | 527 | $this->executeQuery($sql_action, $params_action); |
528 | return $query; | 528 | return true; |
529 | } | 529 | } |
530 | } | 530 | } |
531 | |||
531 | } | 532 | } |
532 | 533 | ||
533 | public function retrieveTagByValue($value) { | 534 | public function retrieveTagByValue($value) { |