diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-05-16 13:31:53 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-05-16 13:31:53 +0200 |
commit | 60c3a4d3e17c991fccfea414b24ebf6e7649c90e (patch) | |
tree | 81eab74b7b5ea649b219451aad8279b3d71bfdbb /inc/poche/Database.class.php | |
parent | 818b186f8aa3f46d7cbddaeca94bd9cec57c213e (diff) | |
parent | 4555c38d3b857bf91ed383f379d9697ed6a79860 (diff) | |
download | wallabag-60c3a4d3e17c991fccfea414b24ebf6e7649c90e.tar.gz wallabag-60c3a4d3e17c991fccfea414b24ebf6e7649c90e.tar.zst wallabag-60c3a4d3e17c991fccfea414b24ebf6e7649c90e.zip |
Merge pull request #689 from tcitworld/dev
Tag-related features
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-x | inc/poche/Database.class.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 141d7987..9e901974 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -511,6 +511,25 @@ 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 cleanUnusedTag($tag_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($tag_id)); | ||
518 | $tagstokeep = $query->fetchAll(); | ||
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($tag_id)); | ||
521 | $alltags = $query->fetchAll(); | ||
522 | |||
523 | foreach ($alltags as $tag) { | ||
524 | if ($tag && !in_array($tag,$tagstokeep)) { | ||
525 | $sql_action = "DELETE FROM tags WHERE id=?"; | ||
526 | $params_action = array($tag[0]); | ||
527 | $this->executeQuery($sql_action, $params_action); | ||
528 | return true; | ||
529 | } | ||
530 | } | ||
531 | |||
532 | } | ||
514 | 533 | ||
515 | public function retrieveTagByValue($value) { | 534 | public function retrieveTagByValue($value) { |
516 | $tag = NULL; | 535 | $tag = NULL; |