我希望能夠從OUT存儲過程中獲取某些輸出,過程也通過select語句返回結果集,如下所示。CDbCommand :: fetchColumn()失敗:SQLSTATE [HY000]:一般錯誤:2014在其他無緩衝查詢處於活動狀態時,無法執行查詢
DELIMITER $$
DROP PROCEDURE IF EXISTS `RD`.`sp`$$
CREATE DEFINER=`root`@`%` PROCEDURE `sp`(in b int, out a int)
BEGIN
select 664656 into a;
select 5;
END$$
DELIMITER ;
一個
call sp(5,@a)
select @a
乳寧在控制檯指令作爲一個下面我們將得到結果 5 => 5 @a => 664656
然而,當我嘗試運行相同代碼從PHP獲取以下錯誤
[error] [system.db.CDbCommand] CDbCommand::fetchColumn() failed:
SQLSTATE[HY000]: General error: 2014 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.. The SQL statement executed was: select @a as result;.
下面的p租賃找到我的PHP代碼。
$connection = Yii::app()->db;
$b=7;
$command = $connection->createCommand ("CALL sp(:b,@a)");
$command->bindParam (":b", $b, PDO::PARAM_INT);
$command->execute();
$command->getPdoStatement()->fetchAll();
$command->getPdoStatement()->closeCursor();
$valueOut = $connection->createCommand ("select @a as result;")->queryScalar();
echo $valueOut;
任何想法如何解決???
PHP版本5.3.1
的Yii 1.1.9版
MySQL版本5.1.41-3ubuntu12.10
任何人都可以幫忙解決問題嗎? –