aboutsummaryrefslogtreecommitdiff
path: root/app/models/Category.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 00:12:18 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 00:12:18 +0200
commit6723babdd65d946cdc7e315d7f11fb3ca0e455d3 (patch)
treee45359332c04fc5c935fbedecd1ade50b6430463 /app/models/Category.php
parent4924f4c6d6d03d39471de363b8d368c8edad8f3d (diff)
ajouts graphique + ajout suppression vieux articles
Diffstat (limited to 'app/models/Category.php')
-rwxr-xr-xapp/models/Category.php22
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 {