Cannot execute queries while other unbuffered queries are active


#1

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.”


#2

do you have a question or something?


#3

Yes. What could be the reason of this error?


#4

#5

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”: https://docs.oxid-esales.com/developer/en/6.0/modules/using_database.html#different-api-methods-for-read-and-write
There was no distinction between read and write in 4.10.


#6

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


#7

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?


#8

@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