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

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

  1. <tfoot id='pN0hU'></tfoot>
  2. <small id='pN0hU'></small><noframes id='pN0hU'>

      <legend id='pN0hU'><style id='pN0hU'><dir id='pN0hU'><q id='pN0hU'></q></dir></style></legend>

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

      mysqli查詢只返回第一行

      mysqli query only returning first row(mysqli查詢只返回第一行)

      <legend id='EBz2Y'><style id='EBz2Y'><dir id='EBz2Y'><q id='EBz2Y'></q></dir></style></legend>
      <tfoot id='EBz2Y'></tfoot>
        <tbody id='EBz2Y'></tbody>

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

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

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

              1. 本文介紹了mysqli查詢只返回第一行的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在從 mysql 遷移到 mysqli,但在查詢中從數(shù)據(jù)庫(kù)返回多于一行時(shí)遇到問題.

                I am migrating from mysql to mysqli, and I am having trouble returning more than one row from the database in a query.

                $db = new mysqli($hostname, $sql_us, $sql_us_pwd, $sql_db); // This is already connected
                
                function db_query($db, $query, $type = 'object') {
                
                    global $db;
                
                    $result = $db->query($query);
                
                    if ($type == 'assoc') {
                        while($row = $result->fetch_assoc()) {
                          return $row;
                        }
                    } else {    
                        while($row = $result->fetch_object()) {
                          return $row;
                        }   
                    }
                
                    mysqli_free_result($result);
                
                }
                
                
                
                $query = "SELECT * FROM `users`";
                $user = db_query($db, $query);
                print_r($user); // This is only returning the first row of results
                

                我顯然是在嘗試創(chuàng)建一個(gè)函數(shù),我可以在其中查詢數(shù)據(jù)庫(kù)并以關(guān)聯(lián)數(shù)組或?qū)ο蟮男问椒祷亟Y(jié)果.我做錯(cuò)了什么?

                I'm obviously trying to make a function where I can query the database and either return the results in an associative array or as an object. What am I doing wrong?

                推薦答案

                使用此代碼:

                $rows = array();
                if ($type == 'assoc') {
                    while($row = $result->fetch_assoc()) {
                      $rows[] = $row;
                    }
                } else {    
                    while($row = $result->fetch_object()) {
                      $rows[] = $row;
                    }   
                }
                return $rows;
                

                您在 while 內(nèi)使用 return 并在第一次迭代后 return 終止 while 循環(huán),這就是為什么您只得到一行.

                You are using the return inside the while and return terminates the while loop after first iteration that's why you are getting only one row.

                這篇關(guān)于mysqli查詢只返回第一行的文章就介紹到這了,希望我們推薦的答案對(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)備好的語(yǔ)句問題)
                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='Ljxuy'><style id='Ljxuy'><dir id='Ljxuy'><q id='Ljxuy'></q></dir></style></legend>

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

                          <tbody id='Ljxuy'></tbody>
                        <tfoot id='Ljxuy'></tfoot>
                          <bdo id='Ljxuy'></bdo><ul id='Ljxuy'></ul>
                          主站蜘蛛池模板: 四色永久 | 一区精品视频 | 免费一级淫片aaa片毛片a级 | 色偷偷噜噜噜亚洲男人 | 欧美成视频 | 欧美一区二区三区视频 | 亚洲人成一区二区三区性色 | 一区二区在线免费观看 | 亚洲精品久久久久久久久久吃药 | 中文字幕久久精品 | 亚洲成人自拍 | www亚洲一区 | 日本一区二区三区免费观看 | 免费观看日韩精品 | 久久大陆 | 日韩成人专区 | 欧美一级大片 | 国产精品亚洲精品 | 国产精品18久久久久久久 | 日韩免费一级 | 欧美日韩久 | 国产成人在线一区二区 | 男人的天堂久久 | 中文字幕在线不卡 | 国产午夜精品一区二区 | 激情的网站| 一本色道精品久久一区二区三区 | 久久精品这里 | 99在线免费观看 | 伊人网在线综合 | 久久久91| 草草草网站 | 中文字幕中文字幕 | а_天堂中文最新版地址 | 欧美中文字幕一区二区三区亚洲 | av手机在线免费观看 | 亚洲成av| 国产高清视频在线播放 | 日韩有码一区 | 日韩成人 | 日本欧美视频 |