开发者社区> 问答> 正文

执行mysql存储过程后Commands out of sync什么原因,求助。

hp调用存储过程后再执行sql就提示
Commands out of sync; you can't run this command now
请问是什么问题?

展开
收起
落地花开啦 2016-06-14 16:55:21 4546 0
2 条回答
写回答
取消 提交回答
  • 感觉要提工单才行

    2019-07-17 19:38:12
    赞同 展开评论 打赏
  • 喜欢技术,喜欢努力的人

    要解决这个问题,需要用mysqli的multi_query方法

    <?php
    $mysqli = new mysqli("localhost", "root", "sbqcel", "test");
    
    if (mysqli_connect_errno()) 
    {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    echo 'result1:<br />';
    $mysqli->autocommit(FALSE);
    if ($mysqli->multi_query("call test1();")) 
    {
        do {
            if ($result = $mysqli->store_result()) {
                while ($row = $result->fetch_row()) {
                    printf("%s\n", $row[0]);
                }
                $result->close();
            }
        } while ($mysqli->next_result());
    }
    $mysqli->commit();
    echo "<br />";
    echo "result2:<br />";
    if ($result2 = $mysqli->query("select val from tb1;")) 
    {
        while ($row = $result2->fetch_row()) {
            printf ("%s <br />", $row[0]);
        }
        $result2->close();
    }
    else
    {
        echo $mysqli->error;
    }
    $mysqli->close();
    ?> 
    2019-07-17 19:38:12
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
One Box: 解读事务与分析一体化数据库 HybridDB for MySQL 立即下载
One Box:解读事务与分析一体化数据库HybridDB for MySQL 立即下载
如何支撑HTAP场景-HybridDB for MySQL系统架构和技术演进 立即下载

相关镜像