由于get_result功能在 PHP 5> = 5.3.0 上可用, PHP 7 是否有人知道热更改此部分代码?
$user = $stmt->get_result()->fetch_assoc()
;
由于我当前使用的主机是php 5.1而且它没有mysqlInd驱动程序我遇到了一些错误。
public function getUserByEmailAndPassword($email, $password) {
$stmt = $this->conn->prepare("SELECT * FROM users 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['encrypted_password'];
$hash = $this->checkhashSSHA($salt, $password);
// check for password equality
if ($encrypted_password == $hash) {
// user authentication details are correct
return $user;
}
} else {
return NULL;
}
}