Skip to content
Advertisement

Laravel – PDO Prepared Statement – Cannot execute queries while other unbuffered queries are active

I am having trouble running the following prepared statement in Laravel:

JavaScript

I get the following error:

[2017-06-08 03:41:35] local.ERROR: PDOException: 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.

This is the entry-point of my controller, so there are definitely no prior queries running.

What do?

Thanks

Advertisement

Answer

The only way I could get it working was to replace the prepared statement with an ‘exec’ call:

JavaScript

I have no idea why it wouldn’t work using a prepared statement in Laravel – it definitely does work with a pure PDO prepared statement.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement