mercredi 12 janvier 2022

Laravel error: Cannot execute queries while other unbuffered queries are active

My Laravel application (version 5.0.33) has suddenly started throwing the following error:

local.ERROR: 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.' in vendor/laravel/framework/src/Illuminate/Database/Connection.php:296

Looking at the relevant line in Connection.php, it appears to be already using 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.
                        $statement = $this->getPdoForSelect($useReadPdo)->prepare($query);

                        $statement->execute($me->prepareBindings($bindings));

                        return $statement->fetchAll($me->getFetchMode());
                });
        }

I also added the following to my config/database.php:

'options' => [ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true ]

But I'm still getting the same error. This application has been working correctly for years, and I hadn't made any changes to the code, so I don't know why this suddenly stared happening. I'm also new to Laravel and didn't write the original code, so I'm not even sure where to start debugging the issue. Can anyone help?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3rgXLLi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire