diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-13 17:06:12 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-13 17:06:12 -0400 |
commit | 74129d1b9e97a5d59f72bd38b70a40a5d21a019f (patch) | |
tree | 2ffe991b24f612f07cd2666cb064812762d32f22 /lib/itemmapper.php | |
parent | 93e7732a7c9d88ba570d95220c7df46a455cb4aa (diff) |
database tables changed
Diffstat (limited to 'lib/itemmapper.php')
-rw-r--r-- | lib/itemmapper.php | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/itemmapper.php b/lib/itemmapper.php index 40693071f..35060f0a4 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -34,6 +34,9 @@ class ItemMapper { $id = $row['id']; $item = new Item($url, $title, $guid, $body, $id); $item->setStatus($status); + $date = $row['date']; + $author = $row['author']; + $item->setAuthor($author); return $item; } @@ -75,13 +78,14 @@ class ItemMapper { return $items; } - public function findIdFromGuid($guid, $feedid){ + public function findIdFromGuid($guid_hash, $guid, $feedid){ $stmt = \OCP\DB::prepare(' SELECT * FROM ' . self::tableName . ' - WHERE guid = ? + WHERE guid_hash = ? AND feed_id = ? '); - $result = $stmt->execute(array($guid, $feedid)); + $result = $stmt->execute(array($guid_hash, $feedid)); + //TODO: if there is more than one row, falling back to comparing $guid $row = $result->fetchRow(); $id = null; if ($row != null){ @@ -120,9 +124,11 @@ class ItemMapper { */ public function save(Item $item, $feedid){ $guid = $item->getGuid(); + $guid_hash = md5($guid); + $status = $item->getStatus(); - $itemid = $this->findIdFromGuid($guid, $feedid); + $itemid = $this->findIdFromGuid($guid_hash, $guid, $feedid); if ($itemid == null){ $title = $item->getTitle(); @@ -130,8 +136,8 @@ class ItemMapper { $stmt = \OCP\DB::prepare(' INSERT INTO ' . self::tableName . - '(url, title, body, guid, feed_id, status) - VALUES (?, ?, ?, ?, ?, ?) + '(url, title, body, guid, guid_hash, feed_id, status) + VALUES (?, ?, ?, ?, ?, ?, ?) '); if(empty($title)) { @@ -143,12 +149,13 @@ class ItemMapper { $l = \OC_L10N::get('news'); $body = $l->t('no body'); } - + $params=array( - htmlspecialchars_decode($item->getUrl()), - htmlspecialchars_decode($title), + $item->getUrl(), + $title, $body, - htmlspecialchars_decode($guid), + $guid, + $guid_hash, $feedid, $status ); |