I made a code a few days ago including get_result()
to receave the results from my database. Today I wantet to add to it and fix some errors. So I tried to use num_rows
to see if anything were returned. But for this I had to use store_result()
. And when I do this get_result()
just returns a boolean of false. When I comment out store_result()
everything works as it should.
I know that the >=
will mess it up. But I put the =
there for debugging(to comment out the store_result()
and see what happend). So that is not the problem
$sql = $this->connect();
$a = $sql->prepare("SELECT `name`, `title`, `comment`, `date` FROM `comment` WHERE `post`=?");
$a->bind_param("s", $id);
$a->execute();
$a->store_result();
if ($a->num_rows >= 0) {
$res = $a->get_result();
var_dump($res);
while ($row = $res->fetch_assoc()) {
$results[] = $row;
}
return $results;
} else {
return false;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…