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

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

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

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

      4. 使用 MySQLi 準(zhǔn)備語句時(shí)無法獲取行數(shù)和獲取

        Cannot get the number of rows and fetch when using MySQLi prepared statement(使用 MySQLi 準(zhǔn)備語句時(shí)無法獲取行數(shù)和獲取)
      5. <tfoot id='4Wf6E'></tfoot>

            <tbody id='4Wf6E'></tbody>

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

            • <small id='4Wf6E'></small><noframes id='4Wf6E'>

                  <bdo id='4Wf6E'></bdo><ul id='4Wf6E'></ul>
                  <legend id='4Wf6E'><style id='4Wf6E'><dir id='4Wf6E'><q id='4Wf6E'></q></dir></style></legend>
                  本文介紹了使用 MySQLi 準(zhǔn)備語句時(shí)無法獲取行數(shù)和獲取的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我想從數(shù)據(jù)庫中獲取行數(shù),但是當(dāng)我嘗試這樣做時(shí),$g_check 變量將等于 0 并且我的代碼將回顯$sugg_title 消息位于 else 語句中.但是在數(shù)據(jù)庫中有 4 個(gè)插入的組,所以 num_rows 屬性應(yīng)該返回 4.

                  I want to get the number of rows from the database, but when I try to do this the $g_check variable will be equal to 0 and my code will echo the $sugg_title message which is in the else statement. But in the database there are 4 inserted groups so the num_rows property should return 4.

                  $sql = "SELECT DISTINCT gp.logo, gp.name
                          FROM gmembers AS gm
                          LEFT JOIN groups AS gp ON gp.name = gm.gname
                          WHERE gp.creator != ? AND gm.mname != ? LIMIT 10";
                  $stmt = $conn->prepare($sql);
                  $stmt->bind_param('ss',$log_username,$log_username);
                  $stmt->execute();
                  $g_check = $stmt->num_rows;
                  if ($g_check > 0){
                    $result = $stmt->get_result();
                    while ($row = $result->fetch_assoc()) {
                      $agList .= '<a href="group.php?g='.$row["name"].'"><img class="group_margin" src="groups/'.$row["name"].'/'.$row["logo"].'" alt="'.$row["name"].'" title="'.$row["name"].'" width="70" height="70" /></a>';
                    }
                  }else{
                    $sugg_title = "You have no group suggestions at the moment. Click ";
                    $sugg_title .= '<a href="all_groups.php">here</a> to view all groups.';
                  }
                  

                  我將 strore_result()fetch() 函數(shù)放在 execute() 之后,但隨后我收到此錯(cuò)誤消息:致命錯(cuò)誤:未捕獲的錯(cuò)誤:在布爾值上調(diào)用成員函數(shù) fetch_assoc()"

                  I put the strore_result() and the fetch() functions after execute() but then I get this error message: "Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean"

                  推薦答案

                  如果要使用mysqli_stmt::$num_rows(即檢查prepared statement上的行數(shù)),你需要在執(zhí)行準(zhǔn)備好的語句后使用 $stmt->store_result() 才能檢查行數(shù).這意味著在我們檢查返回了多少行之前將結(jié)果存儲(chǔ)到內(nèi)存中.

                  If you want to use mysqli_stmt::$num_rows (that is, check the number of rows on the prepared statement), you need to use $stmt->store_result() after executing the prepared statement before being able to check the number of rows. That means that the result is stored into memory before we check how many rows was returned.

                  $stmt = $conn->prepare($sql);
                  $stmt->bind_param('ss',$log_username,$log_username);
                  $stmt->execute();
                  $stmt->store_result(); // Need to store the result into memory first
                  if ($stmt->num_rows) {
                      // ...
                  

                  然而,如果你想使用mysqli_result::$num_rows(在你從語句結(jié)果轉(zhuǎn)換的MySQLi-result上),你需要在執(zhí)行$result = $stmt->get_result();,并使用$result->num_rows;,如下所示.

                  However, if you want to use mysqli_result::$num_rows (on the MySQLi-result you convert from the statement result), you need to do that after doing $result = $stmt->get_result();, and use $result->num_rows;, like shown below.

                  $stmt = $conn->prepare($sql);
                  $stmt->bind_param('ss',$log_username,$log_username);
                  $stmt->execute();
                  $result = $stmt->get_result();
                  if ($result->num_rows) {
                      while ($row = $result->fetch_assoc()) {
                      // ....
                  

                  最后,他們都應(yīng)該做同樣的事情 - 提供原始準(zhǔn)備好的查詢返回的行數(shù).

                  In the end, they should both end up doing the same thing - provide a number of the rows returned by the original prepared query.

                  注意
                  請(qǐng)務(wù)必注意,您不能在同一語句中使用 store_result()get_result().這意味著在第一個(gè)示例中,您不能轉(zhuǎn)換為 mysqli-result 對(duì)象(通過使用 get_result(),它允許您使用標(biāo)準(zhǔn)的 fetch_assoc() 方法).由于 store_result() 將結(jié)果存儲(chǔ)到內(nèi)存中,get_result() 無需轉(zhuǎn)換,反之亦然.

                  Note
                  It's important to note that you cannot use store_result() and get_result() on the same statement. Which means that in the first example, you can not convert to a mysqli-result object (by using get_result(), which allows you to use the standard fetch_assoc() method). As store_result() stores the result into memory, there are nothing for get_result() to convert, and vice-versa.

                  這意味著如果你使用store_result(),你需要通過statement-fetch,mysqli_stmt::fetch()來獲取,并通過綁定結(jié)果>mysqli_stmt::bind_result().如果您使用 get_result(),您應(yīng)該檢查結(jié)果 MySQLi-result 對(duì)象上的行數(shù)(如第二個(gè)示例所示).

                  This means that if you use store_result(), you need to fetch through the statement-fetch, mysqli_stmt::fetch() and bind the results though mysqli_stmt::bind_result(). If you use get_result(), you should check the number of rows on the resulting MySQLi-result object (as shown in the second example).

                  因此,您應(yīng)該構(gòu)建您的代碼,以便您只需要使用其中之一.

                  You should therefor construct your code such that you only need to use one of them.

                  話雖如此,使用 affected_rows 就像評(píng)論中建議的那樣,并不是適合這項(xiàng)工作的工具 - 根據(jù) mysqli_stmt::$affected_rows 上的手冊(同樣的事情適用于常規(guī)查詢,mysqli::$affected_rows):

                  That being said, using affected_rows like suggested in the comments, isn't the right tool for the job - as per the manual on mysqli_stmt::$affected_rows (same thing applies for a regular query, mysqli::$affected_rows):

                  返回受 INSERT、UPDATE 或 DELETE 查詢影響的行數(shù).
                  此函數(shù)僅適用于更新表的查詢.為了從 SELECT 查詢中獲取行數(shù),請(qǐng)改用 mysqli_stmt_num_rows().

                  Returns the number of rows affected by INSERT, UPDATE, or DELETE query.
                  This function only works with queries which update a table. In order to get the number of rows from a SELECT query, use mysqli_stmt_num_rows() instead.

                  • PHP.net mysqli_stmt::store_result()
                  • PHP.net mysqli_stmt::get_result()
                  • PHP.net mysqli_stmt::$num_rows
                  • 這篇關(guān)于使用 MySQLi 準(zhǔn)備語句時(shí)無法獲取行數(shù)和獲取的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調(diào)用未定義的函數(shù) mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準(zhǔn)備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個(gè)結(jié)果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

                  <legend id='Kzg4N'><style id='Kzg4N'><dir id='Kzg4N'><q id='Kzg4N'></q></dir></style></legend>
                    <tbody id='Kzg4N'></tbody>

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

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

                        <bdo id='Kzg4N'></bdo><ul id='Kzg4N'></ul>

                            主站蜘蛛池模板: 国产欧美精品一区二区三区 | 特黄视频 | 大陆一级毛片免费视频观看 | 亚洲国产成人精品女人久久久 | 天天精品在线 | 亚洲综合精品 | 日韩激情一区 | 97精品超碰一区二区三区 | 国产精品一区二区在线观看 | 国产精品日韩高清伦字幕搜索 | 污片在线免费观看 | 日韩精品一区二区三区在线播放 | 免费中文字幕日韩欧美 | 国产精品亚洲第一区在线暖暖韩国 | 男女羞羞视频网站 | 羞羞视频在线观看 | 亚洲成人免费视频在线观看 | 国产日韩欧美精品 | 久久视频一区 | 欧美成人一区二区 | 农村黄性色生活片 | 日本特黄a级高清免费大片 成年人黄色小视频 | 亚洲国产成人久久久 | 一本大道久久a久久精二百 欧洲一区二区三区 | 日韩在线免费看 | 91久色 | 我想看一级黄色毛片 | 精品乱码一区二区 | 台湾佬久久 | 欧美a在线 | 久久99精品久久久久久狂牛 | 欧美日韩国产一区二区 | 区一区二在线观看 | 国产午夜精品一区二区 | 亚洲一视频| 中文字幕11页 | 91精品国产综合久久婷婷香蕉 | 成人免费视频7777777 | 最新中文字幕在线 | 99r在线| 中文字幕免费视频 |