From 07b9460666029a28fc6391ecf17d915eb590dfd2 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 21 Mar 2018 12:21:18 +0100 Subject: [PATCH] Use DB transaction methods of the DB connection (#57) Signed-off-by: Morris Jobke --- db/citymapper.php | 4 ++-- db/settingsmapper.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/citymapper.php b/db/citymapper.php index 9bef9c5..4c48652 100644 --- a/db/citymapper.php +++ b/db/citymapper.php @@ -59,10 +59,10 @@ class CityMapper extends Mapper { } public function create ($userId, $name) { - \OCP\DB::beginTransaction(); + $this->db->beginTransaction(); $query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_city(user_id, name) VALUES (?,?)'); $query->execute(array($userId, $name)); - \OCP\DB::commit(); + $this->db->commit(); $sql = 'SELECT max(id) as maxid FROM *PREFIX*weather_city WHERE user_id = ? and name = ?'; $query = \OCP\DB::prepare($sql); diff --git a/db/settingsmapper.php b/db/settingsmapper.php index c8f5a59..bab1934 100644 --- a/db/settingsmapper.php +++ b/db/settingsmapper.php @@ -37,7 +37,7 @@ class SettingsMapper extends Mapper { } public function setSetting ($settingName, $userId, $settingValue) { - \OCP\DB::beginTransaction(); + $this->db->beginTransaction(); $query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_config ' . 'WHERE `user` = ? and `key` = ?'); $query->execute(array($userId, $settingName)); @@ -45,7 +45,7 @@ class SettingsMapper extends Mapper { $query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_config ' . '(`user`,`key`,`value`) VALUES (?,?,?)'); $query->execute(array($userId, $settingName, $settingValue)); - \OCP\DB::commit(); + $this->db->commit(); } public function getSetting ($userId, $settingName) {