PDO bindValue problem
Posted: Sat Nov 01, 2008 6:13 pm
Code: Select all
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();
}
}So basically key_or_1_var is taken as variable since it is with '' and how to change that to ``?