Sivo 悉见

ThinkPHP5 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

匿名 · 更新于 2017/4/26

错误信息:

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.


也就是说,未结束之前的查询而再次查询,这样是会出错地,所以要释放掉之前的查询。


 

解决办法:
在数据库配置文件中添加配置
[php] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. // 数据库连接参数  
  2.    'params'         => [  
  3.        PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,  
  4.    ],  
  5.