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.php31
1 files changed, 7 insertions, 24 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index a10440edb..8f248e20f 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -164,7 +164,7 @@ INSERT IGNORE INTO `_entry` (
)
SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
FROM `_entrytmp`
-ORDER BY date;
+ORDER BY date, id;
DELETE FROM `_entrytmp` WHERE id <= @rank;
SQL;
@@ -658,6 +658,7 @@ SQL;
}
}
+ /** @return FreshRSS_Entry|null */
public function searchByGuid($id_feed, $guid) {
// un guid est unique pour un flux donné
$sql = 'SELECT id, guid, title, author, '
@@ -669,9 +670,10 @@ SQL;
$stm->bindParam(':guid', $guid);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
- return isset($res[0]) ? self::daoToEntry($res[0]) : null;
+ return isset($res[0]) ? FreshRSS_Entry::fromArray($res[0]) : null;
}
+ /** @return FreshRSS_Entry|null */
public function searchById($id) {
$sql = 'SELECT id, guid, title, author, '
. ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
@@ -681,7 +683,7 @@ SQL;
$stm->bindParam(':id', $id, PDO::PARAM_INT);
$stm->execute();
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
- return isset($res[0]) ? self::daoToEntry($res[0]) : null;
+ return isset($res[0]) ? FreshRSS_Entry::fromArray($res[0]) : null;
}
public function searchIdByGuid($id_feed, $guid) {
@@ -1061,7 +1063,7 @@ SQL;
$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filters, $date_min);
if ($stm) {
while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
- yield self::daoToEntry($row);
+ yield FreshRSS_Entry::fromArray($row);
}
} else {
yield false;
@@ -1092,7 +1094,7 @@ SQL;
$stm = $this->pdo->prepare($sql);
$stm->execute($ids);
while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
- yield self::daoToEntry($row);
+ yield FreshRSS_Entry::fromArray($row);
}
}
@@ -1251,23 +1253,4 @@ SQL;
$unread = empty($res[1]) ? 0 : intval($res[1]);
return array('all' => $all, 'unread' => $unread, 'read' => $all - $unread);
}
-
- public static function daoToEntry($dao) {
- $entry = new FreshRSS_Entry(
- $dao['id_feed'],
- $dao['guid'],
- $dao['title'],
- $dao['author'],
- $dao['content'],
- $dao['link'],
- $dao['date'],
- $dao['is_read'],
- $dao['is_favorite'],
- isset($dao['tags']) ? $dao['tags'] : ''
- );
- if (isset($dao['id'])) {
- $entry->_id($dao['id']);
- }
- return $entry;
- }
}