<i id='7Vt2m'><tr id='7Vt2m'><dt id='7Vt2m'><q id='7Vt2m'><span id='7Vt2m'><b id='7Vt2m'><form id='7Vt2m'><ins id='7Vt2m'></ins><ul id='7Vt2m'></ul><sub id='7Vt2m'></sub></form><legend id='7Vt2m'></legend><bdo id='7Vt2m'><pre id='7Vt2m'><center id='7Vt2m'></center></pre></bdo></b><th id='7Vt2m'></th></span></q></dt></tr></i><div id='7Vt2m'><tfoot id='7Vt2m'></tfoot><dl id='7Vt2m'><fieldset id='7Vt2m'></fieldset></dl></div>

    • <bdo id='7Vt2m'></bdo><ul id='7Vt2m'></ul>
    <tfoot id='7Vt2m'></tfoot>
    1. <small id='7Vt2m'></small><noframes id='7Vt2m'>

      <legend id='7Vt2m'><style id='7Vt2m'><dir id='7Vt2m'><q id='7Vt2m'></q></dir></style></legend>

        PHP:“命令不同步"如果我在调用结果存储过程

        时间:2023-07-29

        <small id='RZAEP'></small><noframes id='RZAEP'>

          • <legend id='RZAEP'><style id='RZAEP'><dir id='RZAEP'><q id='RZAEP'></q></dir></style></legend>
              • <bdo id='RZAEP'></bdo><ul id='RZAEP'></ul>

                1. <tfoot id='RZAEP'></tfoot>
                    <tbody id='RZAEP'></tbody>
                2. <i id='RZAEP'><tr id='RZAEP'><dt id='RZAEP'><q id='RZAEP'><span id='RZAEP'><b id='RZAEP'><form id='RZAEP'><ins id='RZAEP'></ins><ul id='RZAEP'></ul><sub id='RZAEP'></sub></form><legend id='RZAEP'></legend><bdo id='RZAEP'><pre id='RZAEP'><center id='RZAEP'></center></pre></bdo></b><th id='RZAEP'></th></span></q></dt></tr></i><div id='RZAEP'><tfoot id='RZAEP'></tfoot><dl id='RZAEP'><fieldset id='RZAEP'></fieldset></dl></div>

                  本文介绍了PHP:“命令不同步"如果我在调用结果存储过程后再次使用 mysqli::query()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的数据库中有一个存储过程,它返回表中的所有记录:

                  I have a stored procedure in my db that returns all records in a table:

                  CREATE PROCEDURE showAll()
                  BEGIN
                      SELECT * FROM myTable;
                  END
                  

                  SP 工作正常.但是,如果我在 php 脚本中调用它然后我再次尝试查询数据库,它总是失败:

                  The SP works just as expected. But, if I call it in a php script and then I try to query the database again, it always fail:

                  // $mysqli is a db connection
                  
                  // first query:
                  
                  if (!$t = $mysqli->query("call showAll()"))
                      die('Error in the 1st query');
                  
                  while ($r = $t->fetch_row()) {
                      echo $r[0] . "<br>"; // this is ok
                  }
                  
                  $t->free(); // EDIT (this doesn't help anyway)
                  
                  // second query (does the same thing):
                  
                  if (!$t = $mysqli->query("SELECT * from myTable"))
                      die('Error in the 2nd query'); // I always get this error
                  
                  while ($r = $t->fetch_row()) {
                      echo $r[0] . "<br>";
                  }
                  

                  值得注意的是,如果我交换两个查询(即我在最后调用存储过程),它可以正常工作而不会出现任何错误.在第二个查询之前关闭()结果没有帮助.一些提示?

                  Notable, if I swap the two queries (i.e. I call the stored procedure at the end) it works without any error. To close() the result before the second query doesn't help. Some hints?

                  mysqli::error() 是:«命令不同步;您现在无法运行此命令».

                  mysqli::error() is: «Commands out of sync; you can't run this command now».

                  推荐答案

                  mysqli.query 的 php.net/manual 条目的评论已更新,现在包含对此的答案.总而言之,在 $t->close() 之后调用 $mysqli->next_result().向 petrus.jvr 致敬!

                  The comments on the php.net/manual entry for mysqli.query have been updated, and now include an answer for this. To summarize, call $mysqli->next_result() after $t->close(). Kudos to petrus.jvr!

                  链接:http://www.php.net/manual/en/mysqli.query.php#102904

                  这篇关于PHP:“命令不同步"如果我在调用结果存储过程后再次使用 mysqli::query()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:&quot;命令不同步;你现在不能运行这个命令 下一篇:“加载数据本地 infile"不允许命令

                  相关文章

                  最新文章

                  <tfoot id='Dywl5'></tfoot>

                3. <legend id='Dywl5'><style id='Dywl5'><dir id='Dywl5'><q id='Dywl5'></q></dir></style></legend>

                      <bdo id='Dywl5'></bdo><ul id='Dywl5'></ul>
                  1. <i id='Dywl5'><tr id='Dywl5'><dt id='Dywl5'><q id='Dywl5'><span id='Dywl5'><b id='Dywl5'><form id='Dywl5'><ins id='Dywl5'></ins><ul id='Dywl5'></ul><sub id='Dywl5'></sub></form><legend id='Dywl5'></legend><bdo id='Dywl5'><pre id='Dywl5'><center id='Dywl5'></center></pre></bdo></b><th id='Dywl5'></th></span></q></dt></tr></i><div id='Dywl5'><tfoot id='Dywl5'></tfoot><dl id='Dywl5'><fieldset id='Dywl5'></fieldset></dl></div>

                    <small id='Dywl5'></small><noframes id='Dywl5'>