寻找get_result()的替代方案

时间:2017-03-19 07:14:19

标签: php mysqli

我正在寻找几个小时来替代PHP中的函数get_result()。

这是代码:

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;
    }
}

但我收到了错误:

$user = $stmt->get_result()->fetch_assoc();

0 个答案:

没有答案