Reputation: 4331
Is it possible to extract a value from mysqli_result
without fetching a row i.e. without modifying the result set as I need it in full later in my code?
Upvotes: 2
Views: 342
Reputation: 3494
You can also point the iterator back to the beginning. ie..
$result = $mysqli->query($query);
while($row = $result->fetch_assoc())
{
//do stuff with the result
}
//back to the start
mysqli_data_seek($result,0);
now the pointer is returned to the beginning. mysqli_data_seek
Upvotes: 2
Reputation: 11498
You can get all and store in an array…
$results = [];
$sql = mysqli_query($con,"SELECT * FROM WHATEVER");
while ($row = mysqli_fetch_array($sql)) {
array_push($results, $row);
}
//Now $results is fully populated
Upvotes: 0