是否有可能从mysqli_result
中提取值而不获取行,即不修改结果集,因为我需要在以后的代码中完整地使用它?
还可以将迭代器指向起点。ie . .
$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
您可以获取所有并存储在数组中…
$results = [];
$sql = mysqli_query($con,"SELECT * FROM WHATEVER");
while ($row = mysqli_fetch_array($sql)) {
array_push($results, $row);
}
//Now $results is fully populated