summaryrefslogtreecommitdiffstats
path: root/lib/itemmapper.php
diff options
context:
space:
mode:
authorAlessandro <acosenti@malutchosky.(none)>2012-06-02 11:40:35 -0400
committerAlessandro <acosenti@malutchosky.(none)>2012-06-02 11:40:35 -0400
commit3f35d59911ea3e90c4a47249b4a9e7ca49de2cdb (patch)
treec3d0bb3ea07eca40dec65158c9477eb13e33ea08 /lib/itemmapper.php
parente10cdc67c446e768bc4ef8e0b2a73a3def59bcca (diff)
adds delete functions in the mapper
Diffstat (limited to 'lib/itemmapper.php')
-rw-r--r--lib/itemmapper.php35
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/itemmapper.php b/lib/itemmapper.php
index 0d1393409..05aceb28a 100644
--- a/lib/itemmapper.php
+++ b/lib/itemmapper.php
@@ -41,7 +41,8 @@ class OC_News_ItemMapper {
$url = $row['url'];
$title = $row['title'];
$guid = $row['guid'];
- $items[] = new OC_News_Item($url, $title, $guid);
+ $item = new OC_News_Item($url, $title, $guid);
+ $items[] = $item;
}
return $items;
@@ -73,11 +74,12 @@ class OC_News_ItemMapper {
if ($itemid == null){
$title = $item->getTitle();
-
+ $status = $item->getStatus();
+
$query = OCP\DB::prepare('
INSERT INTO ' . self::tableName .
- '(url, title, guid, feed_id)
- VALUES (?, ?, ?, ?)
+ '(url, title, guid, feed_id, status)
+ VALUES (?, ?, ?, ?, ?)
');
if(empty($title)) {
@@ -89,7 +91,8 @@ class OC_News_ItemMapper {
htmlspecialchars_decode($item->getUrl()),
htmlspecialchars_decode($title),
$guid,
- $feedid
+ $feedid,
+ $status
);
$query->execute($params);
@@ -104,7 +107,7 @@ class OC_News_ItemMapper {
* @brief Retrieve an item from the database
* @param id The id of the feed in the database table.
*/
- public static function find($id){
+ public function find($id){
$stmt = OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE id = ?');
$result = $stmt->execute(array($id));
$row = $result->fetchRow();
@@ -114,4 +117,24 @@ class OC_News_ItemMapper {
}
+ //TODO: the delete of an item should mark an item as deleted, not actually delete from the db
+ public function markAsDelete($id){
+ }
+
+ /**
+ * @brief Permanently delete all items belonging to a feed from the database
+ * @param feedid The id of the feed that we wish to delete
+ * @return
+ */
+ public function deleteAll($feedid){
+
+ $stmt = OCP\DB::prepare("
+ DELETE FROM " . self::tableName .
+ "WHERE feedid = $id
+ ");
+
+ $result = $stmt->execute();
+
+ return $result;
+ }
} \ No newline at end of file