aboutsummaryrefslogtreecommitdiff
path: root/app/models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-05 22:12:08 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-05 22:12:08 +0100
commit0e4274fc006203d23b632f4a7a7593427729d649 (patch)
treea1fbf80826c39a8d6ba2b6a7f5bf01510bfa3156 /app/models/Feed.php
parente4cf8a7396d5da06b44a803ce2843361b1077f91 (diff)
Permet de supprimer les articles d'un flux
Implémente https://github.com/marienfressinaud/FreshRSS/issues/311
Diffstat (limited to 'app/models/Feed.php')
-rw-r--r--app/models/Feed.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 1454f44d5..043956f71 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -570,6 +570,34 @@ class FeedDAO extends Model_pdo {
return false;
}
}
+
+ public function truncate ($id) {
+ $sql = 'DELETE e.* FROM `' . $this->prefix . 'entry` e WHERE e.id_feed=?';
+ $stm = $this->bd->prepare($sql);
+ $values = array($id);
+ $this->bd->beginTransaction ();
+ if (!($stm && $stm->execute ($values))) {
+ $info = $stm->errorInfo();
+ Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
+ $this->bd->rollBack ();
+ return false;
+ }
+ $affected = $stm->rowCount();
+
+ $sql = 'UPDATE `' . $this->prefix . 'feed` f '
+ . 'SET f.cache_nbEntries=0, f.cache_nbUnreads=0 WHERE f.id=?';
+ $values = array ($id);
+ $stm = $this->bd->prepare ($sql);
+ if (!($stm && $stm->execute ($values))) {
+ $info = $stm->errorInfo();
+ Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
+ $this->bd->rollBack ();
+ return false;
+ }
+
+ $this->bd->commit ();
+ return $affected;
+ }
}
class HelperFeed {