I am trying to fetch the huge data from server around 500000 rows from database in json format, and getting memory exhausted error. Every thing works fine when I tries with 100 rows, but i need to fetch the 500000 rows in a one go. I am using postman extension to fetch this data. Guys I am not the champ of database but i tried a whole day and found some useful hint this this this and many more but no luck.
I know this is not a good solution but I also tried this ini_set('memory_limit', '-1');
This is what I am doing :
$response["data"] = array();
$result = $db->getData();
while ($data= $result->fetch_assoc()) {
array_push($response["data"], $data);
}
file_put_contents('newData.json', json_encode($response,128));
echoRespnse(200, $response);
I have given my 1 day and tried almost 100's of solution but no luck, I also know this is posted many times, but I thinks my problem is a bit different. Please give your valuable suggestion, every suggestion will be appreciated.