【发布时间】:2015-02-26 15:17:23
【问题描述】:
尝试执行返回大约 100,000 行的查询时出现错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.'
该错误似乎表明多个查询同时运行,但在检查 MySQL 日志时并非如此:
150226 15:10:28 3 Connect root@localhost on Project
3 Query SELECT * FROM Data WHERE posted > '2015-02-01 14:52:28' AND posted < '2015-02-19 18:36:56'
150226 15:11:00 3 Quit
出现这种错误的原因是什么?
由于返回结果的大小,不能选择启用缓冲查询。
【问题讨论】:
-
一些php代码可能会有帮助