是否可以在不提取行的情况下从mysqli_result
中提取值,即不修改结果集,因为我需要在我的代码中完整地需要它?
答案 0 :(得分:2)
您也可以将迭代器指回到开头。即..
$result = $mysqli->query($query);
while($row = $result->fetch_assoc())
{
//do stuff with the result
}
//back to the start
mysqli_data_seek($result,0);
现在指针返回到开头。 mysqli_data_seek
答案 1 :(得分:0)
你可以获得所有并存储在数组中......
$results = [];
$sql = mysqli_query($con,"SELECT * FROM WHATEVER");
while ($row = mysqli_fetch_array($sql)) {
array_push($results, $row);
}
//Now $results is fully populated