From 3f35d59911ea3e90c4a47249b4a9e7ca49de2cdb Mon Sep 17 00:00:00 2001 From: Alessandro Date: Sat, 2 Jun 2012 11:40:35 -0400 Subject: adds delete functions in the mapper --- lib/feedmapper.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/feedmapper.php') diff --git a/lib/feedmapper.php b/lib/feedmapper.php index 737b17d80..e352c7ea7 100644 --- a/lib/feedmapper.php +++ b/lib/feedmapper.php @@ -66,7 +66,7 @@ class OC_News_FeedMapper { * @brief Find the id of a feed and all its items from the database * @param url url of the feed * @return id of the feed corresponding to the url passed as parameters - null - if there is no such feed + * null - if there is no such feed */ public function findIdFromUrl($url){ $stmt = OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE url = ?'); @@ -84,6 +84,7 @@ class OC_News_FeedMapper { * @param feed the feed to be saved * @returns The id of the feed in the database table. */ + //TODO: handle error case public function insert(OC_News_Feed $feed, $folderid){ $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ @@ -132,4 +133,23 @@ class OC_News_FeedMapper { } return $feedid; } + + public function delete(OC_News_Feed $feed){ + + $id = $feed->getId(); + + $stmt = OCP\DB::prepare(" + DELETE FROM " . self::tableName . + "WHERE id = $id + "); + + $result = $stmt->execute(); + + $itemMapper = new OC_News_ItemMapper(); + //TODO: handle the value that the execute returns + $itemMapper->deleteAll($id); + + return true; + + } } \ No newline at end of file -- cgit v1.2.3