问题:在php中用使用mysql方式调用存储过程后无法再执行其它sql执行语句。报错内容:commands out of sync you can't run this command now 。
解决办法:使用mysqli方式,示例代码:
//以下为原生写法,可自行封装 //mysqli连接 $mysqli = new mysqli('host', 'user', 'password', 'dbname'); //主机,用户名,密码,数据库名 $result = []; //调用存储过程 $procedure = "call ProcedureName($params, @outName)"; //数据 if($mysqli->multi_query($procedure)){ do{ if($res = $mysqli->store_result()) { while($row = $res->fetch_array()) { $result[] = $row; } $res->close(); } }while($mysqli->next_result()); } //获取@outName值 $sql = "SELECT @outName"; $que = $mysqli->query($sql); $res = $que->fetch_row(); $out = $res ? $res[0] : '';
共 0 条评论