diff options
| author | 2012-10-25 00:12:18 +0200 | |
|---|---|---|
| committer | 2012-10-25 00:12:18 +0200 | |
| commit | 6723babdd65d946cdc7e315d7f11fb3ca0e455d3 (patch) | |
| tree | e45359332c04fc5c935fbedecd1ade50b6430463 /app/models/Category.php | |
| parent | 4924f4c6d6d03d39471de363b8d368c8edad8f3d (diff) | |
ajouts graphique + ajout suppression vieux articles
Diffstat (limited to 'app/models/Category.php')
| -rwxr-xr-x | app/models/Category.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/models/Category.php b/app/models/Category.php index e0b8f564d..1713f615c 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -23,6 +23,10 @@ class Category extends Model { public function color () { return $this->color; } + public function nbFlux () { + $catDAO = new CategoryDAO (); + return $catDAO->countFlux ($this->id ()); + } public function _id ($value) { $this->id = $value; @@ -76,7 +80,7 @@ class CategoryDAO extends Model_pdo { public function deleteCategory ($id) { $sql = 'DELETE FROM category WHERE id=?'; - $stm = $this->bd->prepare ($sql); + $stm = $this->bd->prepare ($sql); $values = array ($id); @@ -106,20 +110,30 @@ class CategoryDAO extends Model_pdo { public function listCategories () { $sql = 'SELECT * FROM category'; - $stm = $this->bd->prepare ($sql); + $stm = $this->bd->prepare ($sql); $stm->execute (); return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC)); } public function count () { - $sql = 'SELECT COUNT (*) AS count FROM category'; - $stm = $this->bd->prepare ($sql); + $sql = 'SELECT COUNT(*) AS count FROM category'; + $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); return $res[0]['count']; } + + public function countFlux ($id) { + $sql = 'SELECT COUNT(*) AS count FROM feed WHERE category=?'; + $stm = $this->bd->prepare ($sql); + $values = array ($id); + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } } class HelperCategory { |
