From f61df85fe634c7f5662965bb46124af2ecd50419 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 16 Aug 2012 20:26:06 +0200 Subject: made starred items and all items work! --- lib/itemmapper.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'lib/itemmapper.php') diff --git a/lib/itemmapper.php b/lib/itemmapper.php index dcce2a640..03dc1c764 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -64,6 +64,7 @@ class ItemMapper { return $items; } + /** * @brief Retrieve all the items corresponding to a feed from the database with a particular status * @param feedid The id of the feed in the database table. @@ -72,7 +73,8 @@ class ItemMapper { public function findAllStatus($feedid, $status){ $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE feed_id = ? - AND (status & ?)'); + AND (status & ?) + ORDER BY pub_date DESC'); $result = $stmt->execute(array($feedid, $status)); $items = array(); @@ -84,6 +86,29 @@ class ItemMapper { return $items; } + /* + * @brief Retrieve all the items corresponding to a feed from the database with a particular status + * @param feedid The id of the feed in the database table. + * @param status one of the constants defined in OCA\News\StatusFlag + */ + public function findEveryItemByStatus($status){ + $stmt = \OCP\DB::prepare('SELECT ' . self::tableName . '.* FROM ' . self::tableName . ' + JOIN '. FeedMapper::tableName .' ON + '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id + WHERE '. FeedMapper::tableName .'.user_id = ? + AND (' . self::tableName . '.status & ?) + ORDER BY ' . self::tableName . '.pub_date DESC'); + $result = $stmt->execute(array($this->userid, $status)); + + $items = array(); + while ($row = $result->fetchRow()) { + $item = $this->fromRow($row); + $items[] = $item; + } + + return $items; + } + public function countAllStatus($feedid, $status){ $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . ' WHERE feed_id = ? @@ -92,6 +117,16 @@ class ItemMapper { return $result['size']; } + public function countEveryItemByStatus($status){ + $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . ' + JOIN '. FeedMapper::tableName .' ON + '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id + WHERE '. FeedMapper::tableName .'.user_id = ? + AND (' . self::tableName . '.status & ?)'); + $result = $stmt->execute(array($this->userid, $status))->fetchRow();; + + return $result['size']; + } public function findIdFromGuid($guid_hash, $guid, $feedid){ $stmt = \OCP\DB::prepare(' -- cgit v1.2.3