我有来自教程的代码,但我的数据库不支持get_result()。我已经读过您可以使用bind_param()更改它,但我不太确定它是如何工作的。而且我不知道如何在我的情况下应用它
public function getUserByEmailAndPassword($email, $password) {
$stmt = $this->conn->prepare("SELECT * FROM tbl_login WHERE email = ?");
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
// verifying user password
$salt = $user['salt'];
$encrypted_password = $user['password'];
$hash = $this->checkhashSSHA($salt, $password);
// check for password equality
if ($encrypted_password == $hash) {
// user authentication details are correct
return $user;
}
} else {
return NULL;
}
}
如何更改$user = $stmt->get_result()->fetch_assoc();
行以使其仍然可以正常工作?