$stmt = $pdo->query('SELECT * FROM table'); $data = $stmt->fetchAll(); print json_encode($data); Allowed memory size of 268435456 bytes exhausted (tried to allocate 28 bytes).
How to solve this problem?
At the beginning of the script
ini_set('memory_limit','2G'); but I would think about how to rework the algorithm of the web-script too much.
If page loading then you need to get as many elements as there are on the page. This is a bad option for web scripts. Because the memory is not rubber and reserve so much memory is bad for the execution of the script. For it will not be available for other applications and 5-6 (simultaneous) script launches will simply tumble down your server ... This option is not suitable for a less-loaded project.
How to solve this problem?
Do not make queries like SELECT * FROM table , but always request only the data that is needed to display on the page.
And even more so do not use the monstrous crutches from another answer.
И тем более не применять чудовищные костыли из другого ответа. and while the answer does not contain any specific proposals, I will not argue with you. I'm just in my comments to the answers will refer to your comment in this topic and tell people что они пишут кастыли, и быдлокодеры that I would not be banned for it. In general, there will be a full answer, etc. - NaumovSource: https://ru.stackoverflow.com/questions/541758/
All Articles
var_dump($data)to start with, you may have fetchAll with an error running and whereexecutefor the article. - Naumov