当我使用提交表单时,我想更新两个表。我使用此代码,但只更新一个表。如何更新两者?
$cryptpass = password_hash($password, PASSWORD_BCRYPT, array("cost" => 12));
$db = DB();
$query = $db->prepare("UPDATE passrecovery SET resComplete = 'Yes' WHERE email = :email");
$query->closeCursor();
$query = $db->prepare("UPDATE members SET password = :cryptpass WHERE email = :email");
$query->execute(array(
':email' => $row['email'],
':cryptpass' => $cryptpass,
));
print_r("<div class='success'>Success</div>");
答案 0 :(得分:0)
$cryptpass = password_hash($password, PASSWORD_BCRYPT, array("cost" => 12));
$db = DB();
$query = $db->prepare("UPDATE passrecovery p, members m
SET p.resComplete = 'Yes', m.password = :cryptpass
WHERE p.email = m.email and p.email = :email");
$query->execute(array(
':email' => $row['email'],
':cryptpass' => $cryptpass,
));
print_r("<div class='success'>Success</div>");