<?php
$stmt = $mysqli->prepare("SELECT * FROM test WHERE dataStr = ? LIMIT 20");
$stmt->bind_param("s", $search);
$stmt->execute();
$stmt->store_result();
echo "rows are " . $stmt->num_rows;
$rs = $stmt->get_result();
while($r = $rs->fetch_object()) print_r($r);
?>
当我致电$stmt->store_result()
让$stmt->num_rows
工作时,$stmt->get_result()
的后续调用将返回FALSE。如果我评论store_result()
行,一切正常(当然除了num_rows)
在调用mysqli_result
后,如何访问fetch_array()
类实例及其fetch_assoc()
,fetch_object()
,$stmt->store_result()
方法?
答案 0 :(得分:1)
试试这个,
<?php
$stmt = $mysqli->prepare("SELECT * FROM test WHERE dataStr = ? LIMIT 20");
$stmt->bind_param("s", $search);
$stmt->execute();
$stmt->store_result();
echo "rows are " . $stmt->num_rows;
$result = $stmt->get_result();
while ($row = $result->fetch_assoc())
{
echo 'ID: '.$row['id'].'<br>';
}
$stmt->free_result();
?>