function update_user($user_id, $array) {
$result = $this->db->prepare("UPDATE `gcms_user`
SET ?=?
WHERE `user_id`=?;");
$result->bindValue(3, $user_id, PDO::PARAM_INT);
foreach ($array as $key=>$value) {
$result->bindValue(1, $key, PDO::PARAM_STR); // Problem here
$result->bindValue(2, $value, PDO::PARAM_STR);
$result->execute();
}
}
Problem is basic. Query is generated like "UPDATE gcms_user SET 'key_or_1_var'='value_or_2_var' WHERE user_id='#id#';"
So basically key_or_1_var is taken as variable since it is with '' and how to change that to ``?