久久久久久久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>
                          主站蜘蛛池模板: 91精品国产91久久久久久 | 欧美成人激情 | 一区二区免费高清视频 | 久草在线视频中文 | 999热在线视频 | 国产成人综合一区二区三区 | 狠狠躁躁夜夜躁波多野结依 | 国产美女特级嫩嫩嫩bbb片 | 久久91 | 午夜成人在线视频 | 久久午夜剧场 | 天天玩天天操天天干 | 九色国产| 亚洲精品乱码久久久久久久久久 | 日韩亚洲欧美综合 | 国产成人精品一区二区三区视频 | 久久久久9999亚洲精品 | 中文字幕av在线 | 精品国产一区一区二区三亚瑟 | 97精品国产97久久久久久免费 | 国产成人av在线 | 欧美 日韩 国产 成人 | 成人免费视频久久 | 91福利网| 夜色www国产精品资源站 | 亚洲欧美日韩系列 | 国产一区二区三区日韩 | 老司机久久 | 超碰人人人人 | 精品成人在线视频 | 成人在线中文字幕 | 免费的黄色片子 | 久久草在线视频 | 超级黄色一级片 | 亚洲超碰在线观看 | 夜夜精品浪潮av一区二区三区 | 久草热视频 | 欧美一卡二卡在线 | 日韩欧美国产一区二区 | 天堂一区二区三区 | 色网站视频 |