Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/weather.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-07-09 22:05:43 +0300
committerLoic Blot <loic.blot@unix-experience.fr>2015-07-09 22:05:43 +0300
commitcc92ebc7b48c570d043d6cb351c669b9fbf6904e (patch)
treeb22956cbc7f1eb1d68e6b79fc9a7735ca6c13085 /db
parenta70098e142e541a5edb987e810167dd26e74589a (diff)
Add city delete and interface improvements
Diffstat (limited to 'db')
-rw-r--r--db/citymapper.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/db/citymapper.php b/db/citymapper.php
index b7d864c..9472d15 100644
--- a/db/citymapper.php
+++ b/db/citymapper.php
@@ -20,6 +20,31 @@ class CityMapper extends Mapper {
parent::__construct($db, 'weather_city');
}
+ public function load ($id) {
+ $sql = 'SELECT id, name, user_id FROM ' .
+ '*PREFIX*weather_city WHERE id = ?';
+ $query = \OCP\DB::prepare($sql);
+ $result = $query->execute(array($id));
+
+ if ($row = $result->fetchRow()) {
+ return $row;
+ }
+ return null;
+ }
+
+ public function getAll ($userId) {
+ $sql = 'SELECT id, name FROM ' .
+ '*PREFIX*weather_city WHERE user_id = ?';
+ $query = \OCP\DB::prepare($sql);
+ $result = $query->execute(array($userId));
+
+ $cities = array();
+ while ($row = $result->fetchRow()) {
+ $cities[] = $row;
+ }
+ return $cities;
+ }
+
public function create ($userId, $name) {
\OCP\DB::beginTransaction();
$query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_city ' .
@@ -37,5 +62,13 @@ class CityMapper extends Mapper {
}
return null;
}
+
+ public function delete ($id) {
+ \OCP\DB::beginTransaction();
+ $query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_city ' .
+ 'WHERE id = ?');
+ $query->execute(array($id));
+ \OCP\DB::commit();
+ }
};
?>