From 839b6ea2c4e600727912f36ed0ac83ebfa575e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 9 Jan 2014 21:08:00 +0100 Subject: [PATCH] [add] api code for archive entries --- src/Poche/Api/EntryApi.php | 4 ++-- src/Poche/Repository/EntryRepository.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Poche/Api/EntryApi.php b/src/Poche/Api/EntryApi.php index 3dcecd0..31b48f3 100644 --- a/src/Poche/Api/EntryApi.php +++ b/src/Poche/Api/EntryApi.php @@ -11,8 +11,8 @@ class EntryApi $this->contentApi = $contentApi; } - public function getEntries() { - return $this->entryRepository->getEntries(); + public function getEntries($status) { + return $this->entryRepository->getEntries($status); } public function getEntryById($id) { diff --git a/src/Poche/Repository/EntryRepository.php b/src/Poche/Repository/EntryRepository.php index f266610..95643bf 100644 --- a/src/Poche/Repository/EntryRepository.php +++ b/src/Poche/Repository/EntryRepository.php @@ -11,9 +11,9 @@ class EntryRepository } //TODO don't hardcode the user ;) - public function getEntries($userId = 1) { - $sql = "SELECT * FROM entries where user_id = ? AND status = 'unread' ORDER BY id DESC"; - $entries = $this->db->fetchAll($sql, array($userId)); + public function getEntries($status, $userId = 1) { + $sql = "SELECT * FROM entries where user_id = ? AND status = ? ORDER BY id DESC"; + $entries = $this->db->fetchAll($sql, array($userId, $status)); return $entries ? $entries : array(); }