mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-11 01:46:13 +00:00
Use transaction before writing to database
This commit is contained in:
parent
cfc94b253f
commit
3ea5fee350
@ -20,8 +20,8 @@ class SmsMapper extends Mapper {
|
|||||||
parent::__construct($db, 'ocsms_smsdatas');
|
parent::__construct($db, 'ocsms_smsdatas');
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO
|
|
||||||
public function writeToDB($userId, $smsList) {
|
public function writeToDB($userId, $smsList) {
|
||||||
|
\OCP\DB::beginTransaction();
|
||||||
foreach ($smsList as $sms) {
|
foreach ($smsList as $sms) {
|
||||||
$smsFlags = sprintf("%s%s",
|
$smsFlags = sprintf("%s%s",
|
||||||
$sms["read"] === "true" ? "1" : "0",
|
$sms["read"] === "true" ? "1" : "0",
|
||||||
@ -38,7 +38,10 @@ class SmsMapper extends Mapper {
|
|||||||
$sms["address"], $sms["body"], (int) $sms["mbox"],
|
$sms["address"], $sms["body"], (int) $sms["mbox"],
|
||||||
(int) $sms["type"]
|
(int) $sms["type"]
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
\OCP\DB::commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($id) {
|
public function find($id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user