diff options
| author | 2013-12-05 22:12:08 +0100 | |
|---|---|---|
| committer | 2013-12-05 22:12:08 +0100 | |
| commit | 0e4274fc006203d23b632f4a7a7593427729d649 (patch) | |
| tree | a1fbf80826c39a8d6ba2b6a7f5bf01510bfa3156 /app/models | |
| parent | e4cf8a7396d5da06b44a803ce2843361b1077f91 (diff) | |
Permet de supprimer les articles d'un flux
Implémente https://github.com/marienfressinaud/FreshRSS/issues/311
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/Feed.php | 28 |
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 { |
