久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='Ws2h1'></bdo><ul id='Ws2h1'></ul>

    <tfoot id='Ws2h1'></tfoot>

      1. <small id='Ws2h1'></small><noframes id='Ws2h1'>

      2. <i id='Ws2h1'><tr id='Ws2h1'><dt id='Ws2h1'><q id='Ws2h1'><span id='Ws2h1'><b id='Ws2h1'><form id='Ws2h1'><ins id='Ws2h1'></ins><ul id='Ws2h1'></ul><sub id='Ws2h1'></sub></form><legend id='Ws2h1'></legend><bdo id='Ws2h1'><pre id='Ws2h1'><center id='Ws2h1'></center></pre></bdo></b><th id='Ws2h1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ws2h1'><tfoot id='Ws2h1'></tfoot><dl id='Ws2h1'><fieldset id='Ws2h1'></fieldset></dl></div>
        <legend id='Ws2h1'><style id='Ws2h1'><dir id='Ws2h1'><q id='Ws2h1'></q></dir></style></legend>
      3. mysqli 準備好的語句 num_rows 返回 0 而查詢返回大于

        mysqli prepared statement num_rows returns 0 while query returns greater than 0(mysqli 準備好的語句 num_rows 返回 0 而查詢返回大于 0)
          <legend id='m2TjW'><style id='m2TjW'><dir id='m2TjW'><q id='m2TjW'></q></dir></style></legend>

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

              <bdo id='m2TjW'></bdo><ul id='m2TjW'></ul>
                  <tbody id='m2TjW'></tbody>

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

                • 本文介紹了mysqli 準備好的語句 num_rows 返回 0 而查詢返回大于 0的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  對于實際存在的電子郵件,我有一個簡單的準備聲明:

                  I have a simple prepared statement for an email that actually exists:

                  $mysqli = new mysqli("localhost", "root", "", "test");
                  if (mysqli_connect_errno()) {
                      printf("Connect failed: %s
                  ", mysqli_connect_error());
                      exit();
                  }
                  
                  $sql = 'SELECT `email` FROM `users` WHERE `email` = ?';
                  $email = 'example@hotmail.com';
                  
                  if ($stmt = $mysqli->prepare($sql)) {
                      $stmt->bind_param('s', $email);
                      $stmt->execute();
                  
                      if ($stmt->num_rows) {
                          echo 'hello';
                      }
                  
                      echo 'No user';
                  }
                  

                  結果:在應該回顯 hello

                  我在控制臺中運行了相同的查詢,并使用與上述相同的電子郵件得到了結果.

                  I ran the same query in the console and got a result using same email as above.

                  我也使用簡單的 mysqli 查詢進行了測試:

                  I tested using a simple mysqli query as well:

                  if ($result = $mysqli->query("SELECT email FROM users WHERE email = 'example@hotmail.com'")) {
                      echo 'hello';
                  
                  }
                  

                  結果:我所期望的hello

                  還有 $resultnum_rows 是 1.

                  Also $result's num_rows is 1.

                  為什么準備好的語句的num_row不大于0?

                  Why is the prepared statment's num_row not greater than 0?

                  推薦答案

                  當您通過 mysqli 執行語句時,結果實際上并不在 PHP 中,直到您獲取它們——結果由數據庫引擎保存.所以mysqli_stmt對象無法知道執行后立即有多少結果.

                  When you execute a statement through mysqli, the results are not actually in PHP until you fetch them -- the results are held by the DB engine. So the mysqli_stmt object has no way to know how many results there are immediately after execution.

                  像這樣修改你的代碼:

                  $stmt->execute();
                  $stmt->store_result(); // pull results into PHP memory
                  
                  // now you can check $stmt->num_rows;
                  

                  查看手冊

                  這不適用于您的特定示例,但如果您的結果集很大,$stmt->store_result() 將消耗大量內存.在這種情況下,如果您只關心是否至少返回了一個結果,請不要存儲結果;相反,只需檢查結果元數據是否不為空:

                  This doesn't apply to your particular example, but if your result set is large, $stmt->store_result() will consume a lot of memory. In this case, if all you care about is figuring out whether at least one result was returned, don't store results; instead, just check whether the result metadata is not null:

                  $stmt->execute();
                  $hasResult = $stmt->result_metadata ? true : false;
                  

                  查看手冊

                  這篇關于mysqli 準備好的語句 num_rows 返回 0 而查詢返回大于 0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  <legend id='saEiV'><style id='saEiV'><dir id='saEiV'><q id='saEiV'></q></dir></style></legend>

                • <tfoot id='saEiV'></tfoot>
                    <tbody id='saEiV'></tbody>
                  • <bdo id='saEiV'></bdo><ul id='saEiV'></ul>

                      • <small id='saEiV'></small><noframes id='saEiV'>

                            <i id='saEiV'><tr id='saEiV'><dt id='saEiV'><q id='saEiV'><span id='saEiV'><b id='saEiV'><form id='saEiV'><ins id='saEiV'></ins><ul id='saEiV'></ul><sub id='saEiV'></sub></form><legend id='saEiV'></legend><bdo id='saEiV'><pre id='saEiV'><center id='saEiV'></center></pre></bdo></b><th id='saEiV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='saEiV'><tfoot id='saEiV'></tfoot><dl id='saEiV'><fieldset id='saEiV'></fieldset></dl></div>
                            主站蜘蛛池模板: 国产午夜精品一区二区三区四区 | 久久精品国产免费一区二区三区 | 亚洲黄色网址视频 | 日韩国产在线观看 | 国产精品视频999 | 91精品综合久久久久久五月天 | 久久国产精品精品 | 国产一区二区在线免费 | 亚洲欧美精品国产一级在线 | 国产精品第2页 | 亚洲精品一区二区三区在线 | 中文字幕一区在线 | 国产精品免费播放 | 婷婷狠狠 | 中文字幕av一区 | 中文字幕日韩一区二区 | 国产精品久久久久久久久久免费看 | 久久久久久亚洲精品 | av网站免费看 | 九九久久精品 | 一级aaaa毛片 | 成人亚洲视频 | 欧美在线日韩 | 国产成人99久久亚洲综合精品 | 一区二区三区四区在线视频 | 91久久国产综合久久91精品网站 | 日韩精品四区 | 天天干.com| 国产精品视频一区二区三区 | 五月花丁香婷婷 | 中文字幕在线观看av | 精品国产一区二区在线 | 亚洲天天干 | 91麻豆精品国产91久久久久久 | 999久久久久久久久 国产欧美在线观看 | 亚洲国产电影 | 日韩欧美视频在线 | 一区二区三区国产精品 | 亚洲在线中文字幕 | 青青草亚洲| 欧美一区二区三区视频 |