Quote SQL reserved word and fix javascript output.

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign
2022-04-30 16:08:02 -03:00
parent 67cece627d
commit a4bd5d0d90
2 changed files with 4 additions and 10 deletions

View File

@@ -161,14 +161,14 @@ if ($_POST['action'] == 'get_groups') {
}
}
$table_name = ['domainlist_by_group', 'client_by_group', 'adlist_by_group', 'group'];
$table_name = ['domainlist_by_group', 'client_by_group', 'adlist_by_group', '"group"']; //quote reserved word
$table_keys = ['group_id', 'group_id', 'group_id', 'id'];
for ($i = 0; $i < count($table_name); $i++) {
$table = $table_name[$i];
$key = $table_keys[$i];
$stmt = $db->prepare("DELETE FROM ".$table." WHERE ".$key." IN ('.implode(",",$ids).')'");
$stmt = $db->prepare("DELETE FROM ".$table." WHERE ".$key." IN ('".implode("','",$ids)."')");
if (!$stmt) {
throw new Exception("While preparing DELETE FROM $table statement: " . $db->lastErrorMsg());
}