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/Entry.php | |
| parent | 4924f4c6d6d03d39471de363b8d368c8edad8f3d (diff) | |
ajouts graphique + ajout suppression vieux articles
Diffstat (limited to 'app/models/Entry.php')
| -rwxr-xr-x | app/models/Entry.php | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/app/models/Entry.php b/app/models/Entry.php index 437aa8050..6fcc821f4 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -161,6 +161,22 @@ class EntryDAO extends Model_pdo { } } + public function cleanOldEntries ($nb_month) { + $date = 60 * 60 * 24 * 30 * $nb_month; + $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + time () - $date + ); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + return false; + } + } + public function searchById ($id) { $sql = 'SELECT * FROM entry WHERE id=?'; $stm = $this->bd->prepare ($sql); @@ -191,7 +207,7 @@ class EntryDAO extends Model_pdo { } $sql = 'SELECT * FROM entry' . $where . ' ORDER BY date' . $order; - $stm = $this->bd->prepare ($sql); + $stm = $this->bd->prepare ($sql); $stm->execute (); return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); @@ -241,13 +257,22 @@ class EntryDAO extends Model_pdo { } public function count () { - $sql = 'SELECT COUNT (*) AS count FROM entry'; - $stm = $this->bd->prepare ($sql); + $sql = 'SELECT COUNT(*) AS count FROM entry'; + $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); return $res[0]['count']; } + + public function countNotRead () { + $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + + return $res[0]['count']; + } } class HelperEntry { |
