How to get mysql-stored procedure in yii parameters

I am using Yii to work with the mysql stored procedure. Sp takes several parameters, one of which is the output parameter.

After running sp, when I try to get the output parameter, I run an error

CDbCommand did not execute the SQL statement: SQLSTATE [HY000]: General error: 2014 Unable to execute queries while other unbuffered queries are active. Consider using PDOStatement :: fetchAll (). Alternatively, if your code will only work with mysql, you can enable query buffering by setting the PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY attribute. Executed SQL statement: select @error_info as a result;

My code layout is similar:

$sql = 'CALL p_bid(:username, @param)'; $command = Yii::app()->db->createCommand($sql); $command->bindParam(":username", $username, PDO::PARAM_STR); $command->execute(); // the following line raise the error $errorInfo = Yii::app()->db->createCommand("select @error_info as result;")->queryScalar(); 

How can I get around the question? Thanks.

+4
source share
1 answer

Try it works for me

 $command = $connection->createCommand("CALL r emove_places(:user_id,:placeID,:place_type,@out)"); $command->bindParam(":user_id",$user_id,PDO::PARAM_INT); $command->bindParam(":placeID",$placeID,PDO::PARAM_INT); $command->bindParam(":place_type",$place_type,PDO::PARAM_INT); $command->execute(); $valueOut = $connection->createCommand("select @out as result;")->queryScalar(); 
+2
source

Source: https://habr.com/ru/post/1480205/


All Articles