Buffered Queries

I am using the app db connection to run a stored procedure against MySQL5.5:

                $cmd=yii::app()->db->createCommand('call JournalEntry(:_src_id, :_src_type,:_dst_id,:_dst_type,

                    :_src_amount, :_src_currency, :_dst_amount, :_dst_currency, :_description, :_category_id)');












The app error reported is a missing table but what seems to be happening is that it queries the catalog after the procedure has run and that fails - I see the following in the log (attached to the catalog query):

General error: 2014 Cannot execute queries while other unbuffered queries are active.

My procedure call is failing but is closing off any transactions. I have tried various tricks to close the connnection and also tried

Yii::app()->db->pdoInstance->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);

but that doesnt seem to work. Any help would be appreciated!

you could add :



after you call your stored procedure, and everything works again…

i found this,because i have the same problem a mounth ago…

you need to close your connection and then open it again…

hope this helps to other

Thank you - that works! Doesn’t strike me as particularly efficient. Perhaps we will get some comments from yii developers on this.

My guess would be that it has to do with MySQL only compiling and caching queries per DB connection. Once you need to reconnect, the stored procedure is recompiled.

Just an aside, but stored procedures are quite inefficient in MySQL for this reason.

yeah you’re right

i’m happy that i can help you