From 9d0b1712bee30f2302a2d4c4749b07b64318569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 13 Jan 2014 22:15:05 +0100 Subject: [PATCH] [add] method code for get bookmarks --- src/Poche/Api/EntryApi.php | 4 ++++ src/Poche/Repository/EntryRepository.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Poche/Api/EntryApi.php b/src/Poche/Api/EntryApi.php index 866d7a9..04d69b0 100644 --- a/src/Poche/Api/EntryApi.php +++ b/src/Poche/Api/EntryApi.php @@ -15,6 +15,10 @@ class EntryApi return $this->entryRepository->getEntries($status); } + public function getBookmarks() { + return $this->entryRepository->getBookmarks(); + } + public function getEntryById($id) { return $this->entryRepository->getEntryById($id); } diff --git a/src/Poche/Repository/EntryRepository.php b/src/Poche/Repository/EntryRepository.php index b198d3f..0afceb3 100644 --- a/src/Poche/Repository/EntryRepository.php +++ b/src/Poche/Repository/EntryRepository.php @@ -18,6 +18,14 @@ class EntryRepository return $entries ? $entries : array(); } + //TODO don't hardcode the user ;) + public function getBookmarks($userId = 1) { + $sql = "SELECT * FROM entries where user_id = ? AND bookmark = 1 ORDER BY id DESC"; + $entries = $this->db->fetchAll($sql, array($userId)); + + return $entries ? $entries : array(); + } + //TODO don't hardcode the user ;) public function saveEntry($entry, $userId = 1) {