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