我的 Laravel 应用程序(版本 5.0.33)突然开始抛出以下错误:
local.ERROR:异常“PDOException”,消息“SQLSTATE[HY000]:一般错误:2014 当其他未缓冲查询处于活动状态时无法执行查询。考虑使用 PDOStatement::fetchAll()。或者,如果您的代码仅针对 mysql 运行,您可以通过设置 PDO::MYSQL_ATTR_USE_BUFFERED_QUERY 属性来启用查询缓冲。在供应商/laravel/framework/src/Illuminate/Database/Connection.php:296
查看 Connection.php 中的相关行,它似乎已经在使用 fetchAll:
public function select($query, $bindings = array(), $useReadPdo = true)
{
return $this->run($query, $bindings, function($me, $query, $bindings) use ($useReadPdo)
{
if ($me->pretending()) return array();
// For select statements, we'll simply execute the query and return an array
// of the database result set. Each element in the array will be a single
// row from the database table, and will either be an array or objects. …Run Code Online (Sandbox Code Playgroud)