summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-29 13:25:04 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-29 13:30:01 +0200
commit3fc18156ae0b586e8de0c82949acfa6291317536 (patch)
tree201e97511bea44c58b5e9d78d8cf36ae2e2b54f9 /db
parenta03b54c6a59837d0045c140ea7aef3fae95daa95 (diff)
go back to order by id, fix #138, use a newest item id to prevent marking items as read that the user didnt see yet fix #141, also update the starred count periodically
Diffstat (limited to 'db')
-rw-r--r--db/itemmapper.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index ec6d2389e..097479ecc 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -110,7 +110,7 @@ class ItemMapper extends Mapper implements IMapper {
$result = $this->execute($sql, $params)->fetchRow();
- return $result['size'];
+ return (int) $result['size'];
}
@@ -164,40 +164,42 @@ class ItemMapper extends Mapper implements IMapper {
}
- public function findAll($limit, $offset, $newestItemId, $status, $userId){
- $sql = 'AND `items`.`id` < ? ';
- $sql .= 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC ';
- $params = array($userId, $newestItemId);
-
+ public function findAllFeed($id, $limit, $offset, $status, $userId){
+ $params = array($userId, $id);
+ $sql = 'AND `items`.`feed_id` = ? ';
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` < ? ';
+ array_push($params, $offset);
+ }
+ $sql .= 'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql, $status);
- return $this->findAllRows($sql, $params, $limit, $offset);
+ return $this->findAllRows($sql, $params, $limit);
}
- public function findAllFolder($id, $limit, $offset, $newestItemId, $status,
- $userId){
-
- $sql = 'AND `feeds`.`folder_id` = ? ' .
- 'AND `items`.`id` < ? ' .
- 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC ';
- $params = array($userId, $id, $newestItemId);
-
+ public function findAllFolder($id, $limit, $offset, $status, $userId){
+ $params = array($userId, $id);
+ $sql = 'AND `feeds`.`folder_id` = ? ';
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` < ? ';
+ array_push($params, $offset);
+ }
+ $sql .= 'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql, $status);
-
- return $this->findAllRows($sql, $params, $limit, $offset);
+ return $this->findAllRows($sql, $params, $limit);
}
- public function findAllFeed($id, $limit, $offset, $newestItemId, $status,
- $userId){
-
- $sql = 'AND `items`.`feed_id` = ? ' .
- 'AND `items`.`id` < ? ' .
- 'ORDER BY `items`.`pub_date` DESC, `items`.`id` DESC ';
+ public function findAll($limit, $offset, $status, $userId){
+ $params = array($userId);
+ $sql = '';
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` < ? ';
+ array_push($params, $offset);
+ }
+ $sql .= 'ORDER BY `items`.`id` DESC ';
$sql = $this->makeSelectQueryStatus($sql, $status);
- $params = array($userId, $id, $newestItemId);
-
- return $this->findAllRows($sql, $params, $limit, $offset);
+ return $this->findAllRows($sql, $params, $limit);
}