Use DB transaction methods of the DB connection (#57)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>master
parent
e4dbe91f3e
commit
07b9460666
|
@ -59,10 +59,10 @@ class CityMapper extends Mapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create ($userId, $name) {
|
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 = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_city(user_id, name) VALUES (?,?)');
|
||||||
$query->execute(array($userId, $name));
|
$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 = ?';
|
$sql = 'SELECT max(id) as maxid FROM *PREFIX*weather_city WHERE user_id = ? and name = ?';
|
||||||
$query = \OCP\DB::prepare($sql);
|
$query = \OCP\DB::prepare($sql);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class SettingsMapper extends Mapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSetting ($settingName, $userId, $settingValue) {
|
public function setSetting ($settingName, $userId, $settingValue) {
|
||||||
\OCP\DB::beginTransaction();
|
$this->db->beginTransaction();
|
||||||
$query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_config ' .
|
$query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_config ' .
|
||||||
'WHERE `user` = ? and `key` = ?');
|
'WHERE `user` = ? and `key` = ?');
|
||||||
$query->execute(array($userId, $settingName));
|
$query->execute(array($userId, $settingName));
|
||||||
|
@ -45,7 +45,7 @@ class SettingsMapper extends Mapper {
|
||||||
$query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_config ' .
|
$query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_config ' .
|
||||||
'(`user`,`key`,`value`) VALUES (?,?,?)');
|
'(`user`,`key`,`value`) VALUES (?,?,?)');
|
||||||
$query->execute(array($userId, $settingName, $settingValue));
|
$query->execute(array($userId, $settingName, $settingValue));
|
||||||
\OCP\DB::commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetting ($userId, $settingName) {
|
public function getSetting ($userId, $settingName) {
|
||||||
|
|
Loading…
Reference in New Issue