Yii / DAO release connection

If you are doing multiple db connections, you may need to release connections or get an error: “Cannot execute queries while other unbuffered queries are active.”



Where it came up for me was with the “execute()” command, the code I had to use to avoid error was:

$command = Yii::app()->db->createCommand($sql);
$result = $command->execute();
$command = false;

I guess it’s not a bad idea to explicitly close your connections in general.

Leave a Reply