gpt4 book ai didi

php - 简单的 PDO 查询返回内存大小错误

转载 作者:行者123 更新时间:2023-11-29 15:38:12 25 4
gpt4 key购买 nike

我尝试发出一个简单的 pdo 请求来选择表的所有值

<?php public function query($query) { $this->stmt = $this->query($query); } ?>

但是当我这样调用它时

$db->query('SELECT * FROM teams'); $teams = $db->resultset(); print_r($teams);

发生错误

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 65484 bytes) in /var/www/flunky/functions/mysql.class.php on line 29

我尝试增加 php.ini 中的内存大小并使用 ini_set('memory_limit', '512M');,但它不起作用。有人可以帮助我吗?

最佳答案

在运行查询之前运行此代码

$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);

进一步阅读Buffered and Unbuffered queries

I tried to increase the memory size in php.ini and with ini_set('memory_limit', '512M');, but it doesn´t work.

实际上,它有效。

错误消息表明该确切数量已用完。

关于php - 简单的 PDO 查询返回内存大小错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57995306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com