Php 将mysqli_stmt::get_result()转换为bind_result()
我正在尝试将mysqlnd驱动程序安装到我的服务器上,但我的服务器位于云托管站点上。而且不知道如何启用mysqlnd服务器。 因此,我正在尝试另一种方法,使其与当前的php版本兼容 如何将此get\u result方法转换为bind\u resultPhp 将mysqli_stmt::get_result()转换为bind_result(),php,mysql,methods,mysqli,Php,Mysql,Methods,Mysqli,我正在尝试将mysqlnd驱动程序安装到我的服务器上,但我的服务器位于云托管站点上。而且不知道如何启用mysqlnd服务器。 因此,我正在尝试另一种方法,使其与当前的php版本兼容 如何将此get\u result方法转换为bind\u result public function storeUser($name, $email, $password) { $uuid = uniqid('', true); $hash = $this->hashSSHA($password
public function storeUser($name, $email, $password) {
$uuid = uniqid('', true);
$hash = $this->hashSSHA($password);
$encrypted_password = $hash["encrypted"]; // encrypted password
$salt = $hash["salt"]; // salt
$stmt = $this->conn->prepare("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES(?, ?, ?, ?, ?, NOW())");
$stmt->bind_param("sssss", $uuid, $name, $email, $encrypted_password, $salt);
$result = $stmt->execute();
$stmt->close();
// check for successful store
if ($result) {
$stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
return $user;
} else {
return false;
}
}
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(); // m trying to make it bind_result
$stmt->close();
return $user;
} else {
return NULL;
}
}
您是否知道从
用户
获取哪些字段,即您能否用实际的字段标识符替换*
?您在这里试图实现什么?如果您想绑定_result,您需要知道查询结果中调用了哪些列名,除非您想编写大量复杂的代码来动态计算这些字段名。这就是你被要求做的吗?$name、$email、$password是从用户那里获取的。然后在执行后重新编写代码,将变量绑定到这些列名。