1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-11 01:46:13 +00:00

Added optimization: don't to the single deletion if we have purged the DB before, it's useless

This commit is contained in:
Loic Blot 2014-09-15 18:02:45 +02:00
parent ad1353c63c
commit 5d1cababc6

View File

@ -50,13 +50,16 @@ class SmsMapper extends Mapper {
$sms["seen"] === "true" ? "1" : "0"
);
// Remove previous record
// @ TODO: only update the required fields, getAllIds can be useful
$query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
'WHERE user_id = ? AND sms_id = ?');
$result = $query->execute(array(
$userId, (int) $sms["_id"]
));
// Only delete if we haven't purged the DB
if ($purgeAllSmsBeforeInsert === false) {
// Remove previous record
// @ TODO: only update the required fields, getAllIds can be useful
$query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
'WHERE user_id = ? AND sms_id = ?');
$result = $query->execute(array(
$userId, (int) $sms["_id"]
));
}
$query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' .
'(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' .