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(); }