1 回答

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
您需要使用存儲(chǔ)的結(jié)果$query_result,或者通過綁定到變量并獲取它來獲取實(shí)際值。
如果您想使用,get_result()請(qǐng)執(zhí)行以下操作:
public function verifiedUser(string $user_to): bool {
$query = $this->con->prepare("SELECT verified_user FROM users WHERE username = ?");
$query->bind_param("s", $user_to);
$query->execute();
$query_result = $query->get_result();
$row = $query_result->fetch_assoc();
if ($row && $row['verified_user'] == 1) {
return true;
}
return false;
}
如果您想使用,bind_result請(qǐng)執(zhí)行以下操作:
public function verifiedUser(string $user_to): bool {
$query = $this->con->prepare("SELECT verified_user FROM users WHERE username = ?");
$query->bind_param("s", $user_to);
$query->execute();
$query->bind_result($verified_user);
$query->fetch();
return $verified_user == 1;
}
- 1 回答
- 0 關(guān)注
- 142 瀏覽
添加回答
舉報(bào)