DbObjectWithSettings: slightly speed up deletion

This commit is contained in:
Thomas Gelf 2016-02-17 21:41:22 +01:00
parent 4fd0054a59
commit 1d24efd103
1 changed files with 5 additions and 7 deletions

View File

@ -84,8 +84,8 @@ abstract class DbObjectWithSettings extends DbObject
}
}
foreach (array_diff(array_keys($old), array_keys($this->settings)) as $key) {
$del[$key] = $key;
foreach (array_diff($oldKeys, $newKeys) as $key) {
$del[] = $key;
}
$where = sprintf($this->settingsRemoteId . ' = %d AND setting_name = ?', $this->id);
@ -109,11 +109,9 @@ abstract class DbObjectWithSettings extends DbObject
);
}
foreach ($del as $key) {
$db->delete(
$this->settingsTable,
$db->quoteInto($where, $key)
);
if (! empty($del)) {
$where = sprintf($this->settingsRemoteId . ' = %d AND setting_name IN (?)', $this->id);
$db->delete($this->settingsTable, $db->quoteInto($where, $del));
}
}