<bdo id='QkPQK'></bdo><ul id='QkPQK'></ul>
<tfoot id='QkPQK'></tfoot>
      <legend id='QkPQK'><style id='QkPQK'><dir id='QkPQK'><q id='QkPQK'></q></dir></style></legend>

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

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

      2. 为什么mysqli num_rows 总是返回0?

        时间:2023-07-31
          <tbody id='2oOTH'></tbody>
        <i id='2oOTH'><tr id='2oOTH'><dt id='2oOTH'><q id='2oOTH'><span id='2oOTH'><b id='2oOTH'><form id='2oOTH'><ins id='2oOTH'></ins><ul id='2oOTH'></ul><sub id='2oOTH'></sub></form><legend id='2oOTH'></legend><bdo id='2oOTH'><pre id='2oOTH'><center id='2oOTH'></center></pre></bdo></b><th id='2oOTH'></th></span></q></dt></tr></i><div id='2oOTH'><tfoot id='2oOTH'></tfoot><dl id='2oOTH'><fieldset id='2oOTH'></fieldset></dl></div>

              <bdo id='2oOTH'></bdo><ul id='2oOTH'></ul>
              <legend id='2oOTH'><style id='2oOTH'><dir id='2oOTH'><q id='2oOTH'></q></dir></style></legend>
              • <tfoot id='2oOTH'></tfoot>
              • <small id='2oOTH'></small><noframes id='2oOTH'>

                  本文介绍了为什么mysqli num_rows 总是返回0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直无法使用 mysqli 获取要返回的行数.尽管肯定有一些结果,但我每次都只返回 0.

                  I've been having trouble getting the number of rows to return using mysqli. I just get 0 back every time even though there are definitely some results.

                  if($stmt = $mysqli->prepare("SELECT id, title, visible, parent_id FROM content WHERE parent_id = ? ORDER BY page_order ASC;")){  
                      $stmt->bind_param('s', $data->id);  
                      $stmt->execute();
                      $num_of_rows = $stmt->num_rows;  
                      $stmt->bind_result($child_id, $child_title, $child_visible, $child_parent);  
                  
                      while($stmt->fetch()){
                          //code
                      }
                  
                      echo($num_of_rows);
                  
                      $stmt->close();
                  }
                  

                  为什么不显示正确的数字?

                  Why doesn't it show the correct number?

                  推荐答案

                  需要调用mysqli_stmt::store_result() 在 num_rows 查找之前:

                  You need to call mysqli_stmt::store_result() prior to the num_rows lookup:

                  if($stmt = $mysqli->prepare("SELECT id, title, visible, parent_id FROM content WHERE parent_id = ? ORDER BY page_order ASC;")){  
                      $stmt->bind_param('s', $data->id);  
                      $stmt->execute();
                      $stmt->store_result(); <-- This needs to be called here!
                      $num_of_rows = $stmt->num_rows;  
                      $stmt->bind_result($child_id, $child_title, $child_visible, $child_parent);  
                  
                      while($stmt->fetch()){
                          //code
                      }
                  
                      echo($num_of_rows);
                  
                      $stmt->close();
                  }
                  

                  请参阅 mysqli_stmt::num_rows 上的文档,它就在页面顶部附近(在主描述块中).

                  See the docs on mysqli_stmt::num_rows, it says it right near the top of the page (in the main description block).

                  这篇关于为什么mysqli num_rows 总是返回0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:致命错误:在非对象上调用成员函数 fetch_assoc() 下一篇:为什么我不能运行两个 mysqli 查询?第二个失败

                  相关文章

                  最新文章

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

                    2. <small id='i51zg'></small><noframes id='i51zg'>

                    3. <tfoot id='i51zg'></tfoot>
                    4. <legend id='i51zg'><style id='i51zg'><dir id='i51zg'><q id='i51zg'></q></dir></style></legend>
                        <bdo id='i51zg'></bdo><ul id='i51zg'></ul>