aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php34
1 files changed, 10 insertions, 24 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index d2e7664fc..ebe530ec1 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -634,8 +634,7 @@ SQL;
$stm->bindParam(':guid', $guid);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
- $entries = self::daoToEntries($res);
- return isset($entries[0]) ? $entries[0] : null;
+ return isset($res[0]) ? self::daoToEntry($res[0]) : null;
}
public function searchById($id) {
@@ -647,8 +646,7 @@ SQL;
$stm->bindParam(':id', $id, PDO::PARAM_INT);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
- $entries = self::daoToEntries($res);
- return isset($entries[0]) ? $entries[0] : null;
+ return isset($res[0]) ? self::daoToEntry($res[0]) : null;
}
public function searchIdByGuid($id_feed, $guid) {
@@ -885,15 +883,17 @@ SQL;
public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filters = null, $date_min = 0) {
$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filters, $date_min);
if ($stm) {
- return self::daoToEntries($stm->fetchAll(PDO::FETCH_ASSOC));
+ while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
+ yield self::daoToEntry($row);
+ }
} else {
- return false;
+ yield false;
}
}
public function listByIds($ids, $order = 'DESC') {
if (count($ids) < 1) {
- return array();
+ yield false;
}
$sql = 'SELECT id, guid, title, author, '
@@ -905,7 +905,9 @@ SQL;
$stm = $this->pdo->prepare($sql);
$stm->execute($ids);
- return self::daoToEntries($stm->fetchAll(PDO::FETCH_ASSOC));
+ while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
+ yield self::daoToEntry($row);
+ }
}
public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filters = null) { //For API
@@ -1058,20 +1060,4 @@ SQL;
}
return $entry;
}
-
- private static function daoToEntries($listDAO) {
- $list = array();
-
- if (!is_array($listDAO)) {
- $listDAO = array($listDAO);
- }
-
- foreach ($listDAO as $key => $dao) {
- $list[] = self::daoToEntry($dao);
- }
-
- unset($listDAO);
-
- return $list;
- }
}