更新
$stmt = $this->db->prepare("
SELECT u.id, u.fname, u.lname, u.mname, u.type, u.email, u.salt,
u.pass, u.salt, u.approved, u.ban, u2.status
FROM `users` AS u
LEFT OUTER JOIN `log` AS u2
ON u2.user_id = u.id
WHERE u.email = ? LIMIT 1") or die($this->db->error);
$stmt->bind_param("s", $_POST['email']) or die($stmt->error);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 0) {
die($this->ajax->respond(7));
}
$result = $stmt->get_result();
$data = $result->fetch_array(MYSQLI_BOTH);
尝试获取数组,但最后一行出现以下错误
Fatal error: Call to a member function fetch_array() on a non-object
无法正常工作。请帮忙
最佳答案
$data = $stmt->fetchAll();
为此,PDO提供了这种漂亮的功能。
编辑:我认为这是PDO接口。为什么不使用pdo?我觉得它比mysqli舒服。
关于php - PHP准备语句的Fetch_array替代方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9050143/