diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-02-15 17:01:00 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-02-15 17:01:00 +0100 |
commit | 0368e1e3ce51647869a00cd08871a7baf29de19f (patch) | |
tree | f9ccab09df14378490a7f6979fef490a1e72c31a /db | |
parent | bec3f917c331a17841da9aac7dad510707b24492 (diff) |
When passing a negative batchSizes to the item API, all items will be returned
Diffstat (limited to 'db')
-rw-r--r-- | db/itemmapper.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php index dec80894f..a41ecfd66 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -172,6 +172,16 @@ class ItemMapper extends NewsMapper { } + private function findEntitiesIgnoringNegativeLimit($sql, $params, $limit) { + // ignore limit if negative to offer a way to return all feeds + if ($limit >= 0) { + return $this->findEntities($sql, $params, $limit); + } else { + return $this->findEntities($sql, $params); + } + } + + public function findAllFeed($id, $limit, $offset, $status, $oldestFirst, $userId){ $params = [$userId, $id]; @@ -182,7 +192,7 @@ class ItemMapper extends NewsMapper { $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); - return $this->findEntities($sql, $params, $limit); + return $this->findEntitiesIgnoringNegativeLimit($sql, $params, $limit); } @@ -196,7 +206,7 @@ class ItemMapper extends NewsMapper { $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); - return $this->findEntities($sql, $params, $limit); + return $this->findEntitiesIgnoringNegativeLimit($sql, $params, $limit); } @@ -209,7 +219,8 @@ class ItemMapper extends NewsMapper { $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); - return $this->findEntities($sql, $params, $limit); + + return $this->findEntitiesIgnoringNegativeLimit($sql, $params, $limit); } |