Hello,
using a Stored Procedure returning multiple row sets that can not be altered, on an Apache-PHP-MSSQL-Stack running on Windows using sqlsrv as driver yields the error:
CDbCommand failed to execute the SQL statement: SQLSTATE[IMSSP]: The active result for the query contains no fields
This behaviour did not cause problems w/ other drivers as they seemingly ignored multiple result sets. The usual fix to this problem uses sqlsrv_next_result() until a different error occurred or we have exhausted the row sets.
Being new to Yii, the only solution I could muster was modifying CDbCommand.php which is obviously not an option for production mode. Here’s my modifications starting from CDbCommand.php#515:
// 2013-10-21 (kiewiet): Dear god... there must be some other
// way to do this properly w/o modifying library code; ask
// on the forums.
$retry_hack = false;
do {
try {
$result=$this->_statement->$method();
$retry_hack = false; // won't get here on throw
}
catch (PDOException $e) {
// If we do not have any more rowsets we obviously have
// a proper exception at this point and just re-throw
// it to whomever wants to catch it.
if (!($retry_hack = true === $this->_statement->nextRowset())) {
throw $e;
}
}
} while ($retry_hack);
So my question is now: how can I introduce this behaviour at a low level (i.e. so that AR classes still work, etc.) without actually modifying the library code?
Best Regards,
Christian