diff options
| author | 2019-12-18 09:26:17 +0100 | |
|---|---|---|
| committer | 2019-12-18 09:26:17 +0100 | |
| commit | 2b1f8e67f76672a5b1b0a1b0403d81dbee364c58 (patch) | |
| tree | ab3142289e260111c686e740b9f4214453a0a84c /app/Models | |
| parent | 90c7292326538522a5df97b3f0a847b8a28f759f (diff) | |
| parent | 82851d2039f619f1b2558e06b04a9e47fceeea54 (diff) | |
Merge branch 'dev'
This is the end of the `dev` branch. Good bye old friend!
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/FeedDAO.php | 33 | ||||
| -rw-r--r-- | app/Models/FeedDAOSQLite.php | 1 | ||||
| -rw-r--r-- | app/Models/Share.php | 18 |
3 files changed, 50 insertions, 2 deletions
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 2bff50d52..417b37773 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -421,6 +421,29 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $affected; } + public function purge() { + $sql = 'DELETE FROM `_entry`'; + $stm = $this->pdo->prepare($sql); + $this->pdo->beginTransaction(); + if (!($stm && $stm->execute())) { + $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + Minz_Log::error('SQL error truncate: ' . $info[2]); + $this->pdo->rollBack(); + return false; + } + + $sql = 'UPDATE `_feed` SET `cache_nbEntries` = 0, `cache_nbUnreads` = 0'; + $stm = $this->pdo->prepare($sql); + if (!($stm && $stm->execute())) { + $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + Minz_Log::error('SQL error truncate: ' . $info[2]); + $this->pdo->rollBack(); + return false; + } + + $this->pdo->commit(); + } + public static function daoToFeed($listDAO, $catID = null) { $list = array(); @@ -481,4 +504,14 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm->execute(array(':new_value' => -3600, ':old_value' => -1)); } } + + public function count() { + $sql = 'SELECT COUNT(e.id) AS count FROM `_feed` e'; + $stm = $this->pdo->query($sql); + if ($stm == false) { + return false; + } + $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); + return isset($res[0]) ? $res[0] : 0; + } } diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php index 0f685867a..397b69941 100644 --- a/app/Models/FeedDAOSQLite.php +++ b/app/Models/FeedDAOSQLite.php @@ -13,5 +13,4 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO { } return false; } - } diff --git a/app/Models/Share.php b/app/Models/Share.php index 7378b30df..cf9966a4b 100644 --- a/app/Models/Share.php +++ b/app/Models/Share.php @@ -76,6 +76,7 @@ class FreshRSS_Share { private $help_url = ''; private $custom_name = null; private $base_url = null; + private $id = null; private $title = null; private $link = null; private $method = 'GET'; @@ -118,12 +119,13 @@ class FreshRSS_Share { /** * Update a FreshRSS_Share object with information from an array. * @param $options is a list of informations to update where keys should be - * in this list: name, url, title, link. + * in this list: name, url, id, title, link. */ public function update($options) { $available_options = array( 'name' => 'custom_name', 'url' => 'base_url', + 'id' => 'id', 'title' => 'title', 'link' => 'link', 'method' => 'method', @@ -196,11 +198,13 @@ class FreshRSS_Share { */ public function url() { $matches = array( + '~ID~', '~URL~', '~TITLE~', '~LINK~', ); $replaces = array( + $this->id(), $this->base_url, $this->title(), $this->link(), @@ -209,6 +213,18 @@ class FreshRSS_Share { } /** + * Return the id. + * @param $raw true if we should get the id without transformations. + */ + public function id($raw = false) { + if ($raw) { + return $this->id; + } + + return $this->transform($this->id, $this->getTransform('id')); + } + + /** * Return the title. * @param $raw true if we should get the title without transformations. */ |
