From 0f2891f4325d6f88845790393d006883831118fd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Oct 2012 22:30:40 +0100 Subject: Fix issue #8 : ajoute le nombre de non lus pour les catégories (mérite amélioration ?) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Category.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/models') diff --git a/app/models/Category.php b/app/models/Category.php index 47ed913c9..ceecea453 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -27,6 +27,10 @@ class Category extends Model { $catDAO = new CategoryDAO (); return $catDAO->countFeed ($this->id ()); } + public function nbNotRead () { + $catDAO = new CategoryDAO (); + return $catDAO->countNotRead ($this->id ()); + } public function _id ($value) { $this->id = $value; @@ -134,6 +138,16 @@ class CategoryDAO extends Model_pdo { return $res[0]['count']; } + + public function countNotRead ($id) { + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE category=? AND e.is_read=0'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } } class HelperCategory { -- cgit v1.2.3