//Update Data Into Multiple Columns
function updateAllColumns($table, $where = '', ...$params): bool
{
global $db;
$sql = "UPDATE $table SET ";
foreach ($params[0] as $key => $val) {
if ($val != 'NULL') {
$sql .= "`{$key}`=" . "'{$val}' ,";
} else {
$sql .= "`{$key}`=" . ' NULL' . ",";
}
}
if ($where) {
$sql .= ' WHERE ' . $where . ' ';
}
$sql = substr_replace($sql, '', strrpos($sql, ','), 1);
$result = $db->query($sql);
if ($result) {
return true;
} else {
return false;
}
}