PHP PDOException: “SQLSTATE[HY093]: Invalid parameter number”
当我尝试运行以下函数时,我收到错误“SQLSTATE[HY093]:无效的参数编号”:
function add_persist($db, $user_id) {
$hash = md5("per11".$user_id."sist11".time());
$future = time()+(60*60*24*14);
$sql = "INSERT INTO persist (user_id, hash, expire) VALUES (:user_id, :hash, :expire) ON DUPLICATE KEY UPDATE hash=:hash";
$stm = $db->prepare($sql);
$stm->execute(array(":user_id" => $user_id, ":hash" => $hash, ":expire" => $future));
return $hash;
}
我觉得这是一件简单的事情,我只是没有抓住。有什么想法吗?