Cannot execute queries while other unbuffered queries are active

I tried to run a module that was written for oxid 4.10 on oxid 6. And I get an error in this piece of code

$oArtList = oxNew('oxarticlelist');
$oArtList->selectString('SELECT * FROM oxarticles WHERE OXACTIVE=1');

The error says “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.”

do you have a question or something?

Yes. What could be the reason of this error?

I think the error is not really caused by these lines, it’s something that happened before. It might be caused by a select using “execute” and not “select”: Interacting with the database — OXID eShop developer documentation 6.0.0 documentation
There was no distinction between read and write in 4.10.

1 Like

Yes, I found where SELECT query was executed via execute() and replaced it with select(). Thanks a lot:)

I have the same mistake, but the solution to the problem is not relevant to me. I use “DatabaseProvider :: getDb () -> execute (…)” not for selects but for DB commands like “Alter Table”, “Drop”, “Delete”. My error is thrown during a module installation routine (onActivate) where the database is adjusted several times. So what do I have to do to enable query buffering for this case?
Or is there another way I can quickly execute the above commands?

@all: I found my mistake. One of my executes Methods has yet made a “select”-SQL-Call.
So the solution was exactly as already described.
Thanks for all

3 Likes