I have a PHP script which returns lots of rows from my MySQL DB. Usually no issue occurs but occasionally a large amount of rows are returned which causes memory exhaustion.
The fetch is here:
$fetchall = mysqli_fetch_all($getPrepData->get_result(), MYSQLI_ASSOC);
I am wondering what an alternative is the mysqli_fetch_all
which would be better for memory to prevent this issue without increasing memory limit etc
Update:
I have added the following as suggested in the comments
$result = $getPrepData->get_result();
$data = [];
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
But I still get a memory error on this line:
$result = $getPrepData->get_result();