I created the following function in the user class:
public function update_usermeta($user_id,$user_profile)
{
$sql = 'INSERT INTO users_meta
(user_id,meta_key,meta_value)
VALUES (:user_id,:meta_key,:meta_value)
ON DUPLICATE KEY
UPDATE meta_value = :meta_value';
foreach ($user_profile as $meta_key => $meta_value) {
if ($meta_value == null OR $meta_value == "") {continue;}
if ($meta_key == "identifier" OR $meta_key == "photoURL" OR $meta_key == "displayName" OR $meta_key == "email") {continue;}
$params = array(
':meta_key' => $meta_key,
':meta_value' => $meta_value,
':user_id' => $user_id
);
$this->mysql_execute_query($sql,$params);
}
}
The insert works fine, but I have a problem with the ON DUPLICATE part, it has an error:
SQLSTATE[HY093]: Invalid parameter number
Obviously, the problem is that I have more options than required for the update. How to resolve this situation?
user796443
source
share