$sql = "UPDATE product_list SET product_name='".$product_name."',product_category='".$product_category."',product_price='".$product_price."',product_description='".$product_description."',size_category='".$size_category."'";
//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;
}
}
//Insert Data Into Multiple Columns
//$params= Array Value array('me_title' => $_POST['me_title'])
function insertData($table, $params)
{
global $db;
$columns = array_keys($params);
$values = array_values($params);
$sql = "INSERT INTO $table (" . implode(',', $columns) . ") VALUES ('" . implode("', '", $values) . "' )";
$result = $db->query($sql);
$insertId = $db->getInsertId();
if ($result) {
return $insertId;
} else {
return false;
}
}