久久久久久久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查詢只返回第一行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

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

                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)建一個函數(shù),我可以在其中查詢數(shù)據(jù)庫并以關(guān)聯(lián)數(shù)組或?qū)ο蟮男问椒祷亟Y(jié)果.我做錯了什么?

                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查詢只返回第一行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 只返回一個結(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>
                          主站蜘蛛池模板: 日本午夜精品 | 99精品视频免费观看 | 久草在线中文888 | 亚洲欧美在线观看 | 91欧美| 亚洲精品久久久蜜桃网站 | 美日韩免费视频 | 午夜免费电影 | 久久一二 | 成人做爰69片免费观看 | 国产乱码精品一区二区三区忘忧草 | 精品1区 | 国产精品国产成人国产三级 | 久久丝袜 | 成人久久久 | 亚洲精品日韩在线 | 国产视频久久久 | 精品av久久久久电影 | 中文字幕一区二区三区精彩视频 | 亚洲图片视频一区 | 美女黄网站视频免费 | 天天操天天天 | 国产乱码精品一区二三赶尸艳谈 | 亚洲国产精品99久久久久久久久 | 91国内外精品自在线播放 | 99热播精品 | 一区二区三区国产 | 日本在线观看视频 | 一级毛片色一级 | 日韩av在线免费 | 婷婷成人在线 | 特黄一级 | 亚洲www | 欧美日韩免费一区二区三区 | 国产一区二区免费 | 亚洲女优在线播放 | 久久久久精 | 91免费看片神器 | 黄色大片视频 | 欧美电影在线 | 欧美日韩视频在线播放 |