I'm developing an application where, in a report, I need to print something around 50,000 lines. When executing SELECT the error occurs:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in C: \ wamp \ www \ simplaFramework \ System \ Framework \ Model.class.class.php on line 884.
The result of the following query is being saved in array
because I will treat it later:
$data = array();
$count = 0;
while ($row = $q->fetch($pdo_fetch)) {
$data[] = $row;
++$count;
}
My idea was to split the result into 2 or more arrays whenever it reaches an X amount of memory usage.
For example: when using approximate 128mb (I get this value with memory_get_usage()
) I divide the result into 2 or more arrays and return the result.
But how can I do this? Should I use a Buffer?