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

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

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

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

  • <tfoot id='HqnAu'></tfoot>
        • <bdo id='HqnAu'></bdo><ul id='HqnAu'></ul>

        PHP:查詢結(jié)果如何存儲在 mysqli_result 中

        PHP: how are query results stored in mysqli_result(PHP:查詢結(jié)果如何存儲在 mysqli_result 中)

              <tbody id='ZLyRU'></tbody>

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

                  本文介紹了PHP:查詢結(jié)果如何存儲在 mysqli_result 中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  當(dāng)我查詢數(shù)據(jù)庫并在mysqli_result中檢索結(jié)果時,內(nèi)存使用量極小.但是,當(dāng)我將查詢結(jié)果中的所有行提取到關(guān)聯(lián)數(shù)組中時,內(nèi)存使用率變得非常高.

                  When I made a query to the database and retrieve the results in mysqli_result, the memory usage is extremely small. However, when I fetch all the rows in the query results in to an associative array, the memory usage becomes extremely high.

                  <?php
                      require_once("../config.php"); //db connection config
                      $db = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_DBASE);
                  
                      $query ="select * from table_name";
                      if($r = $db->query($query)){
                      echo "MEMORY USAGE before :  ". memory_get_usage()."<br><br>";
                      $rows = array();
                      while($row = $r->fetch_assoc()){
                  
                          $rows[]= $row;
                      }
                      echo "MEMORY USAGE after :  ". memory_get_usage()."<br><br>";
                  
                  
                      //before: 660880
                      //after:  114655768
                      // # of records: around 30 thousands
                  ?>
                  

                  對我來說,存儲這么多結(jié)果非常消耗內(nèi)存是有道理的,但我只是想知道 mysqli_result 怎么這么小.不可能是每次調(diào)用fetch_assoc的時候都向dbase查詢結(jié)果.那么結(jié)果存儲在內(nèi)存中的什么地方.

                  It makes sense to me that storing this many results is very memory consuming, but I'm just wondering how come mysqli_result is so small. It can't be that the results are queried to the dbase every time fetch_assoc is called. So then where are the results stored in the memory.

                  推薦答案

                  獲取結(jié)果和存儲指向資源的指針之間存在巨大差異.

                  There is a HUGE difference between fetching results and storing a pointer to a resource.

                  如果你在第一次調(diào)用 memory_get_usage(); 之前 echo $r;,你會意識到它只是一個指針.這是指向結(jié)果集的指針.在您獲取結(jié)果之前,結(jié)果集實際上不會存儲到內(nèi)存中.

                  If you echo $r; before your first call to memory_get_usage();, you will realize it is just a pointer. This is the pointer to your result set. Until you fetch your results, the result set will not actually be stored into memory.

                  我建議您運行 fetchAll() 來執(zhí)行您要執(zhí)行的操作.這將導(dǎo)致 1 個方法以更好的性能訪問您的所有結(jié)果,因為它是在 mysqli 擴展(C 庫)而不是 PHP 中的循環(huán)上典當(dāng)?shù)?

                  I would suggest that you run fetchAll() for what you are trying to do. This will then result in 1 method accessing all your results with better performance since it's pawned off on the mysqli extension (C Library) rather than a loop in PHP.

                  您還可以使用免費結(jié)果功能在完成后從內(nèi)存中清除結(jié)果.如果您熟悉,這就像在 Java 中關(guān)閉游標一樣.

                  You can also use the free results function to clear your results from memory when you are done with them. This is like closing a cursor in Java if you are familiar.

                  這篇關(guān)于PHP:查詢結(jié)果如何存儲在 mysqli_result 中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                  <legend id='IPwYC'><style id='IPwYC'><dir id='IPwYC'><q id='IPwYC'></q></dir></style></legend>
                    <tbody id='IPwYC'></tbody>

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

                    <tfoot id='IPwYC'></tfoot>

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

                            主站蜘蛛池模板: 日韩欧美久久精品 | 国产精品精品视频一区二区三区 | 精品在线一区 | 九九热这里 | 亚洲国产精品久久久久久 | 91精品一区 | 国产福利91精品 | 国产成人精品午夜视频免费 | 国产精品我不卡 | 在线观看h视频 | 欧美日韩国产三级 | 欧美精品区 | 伊人国产精品 | 亚洲视频中文字幕 | 亚洲综合二区 | 视频一区二区在线 | 免费黄色片在线观看 | 超级乱淫av片免费播放 | 久在线| 91久久精品日日躁夜夜躁国产 | 亚洲精品一区在线观看 | 精品久久久久久久人人人人传媒 | www.日韩 | av久久 | 蜜臀网站 | 久久中文免费视频 | 成人黄色在线视频 | 国产在线看片 | www.亚洲区 | 亚洲成人日韩 | 欧美一区二区三区电影 | 久草色视频 | 亚洲一区二区三区在线视频 | 色婷婷精品久久二区二区蜜臂av | av一区在线观看 | 日一日操一操 | 国产日本精品视频 | 精品久久久久久久久久久久 | 97人澡人人添人人爽欧美 | 国产午夜精品久久 | 成人免费视频网址 |