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

  • <legend id='YwhoV'><style id='YwhoV'><dir id='YwhoV'><q id='YwhoV'></q></dir></style></legend>

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

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

        php PDO fetchAll() - 雖然不工作,但 foreach 工作

        php PDO fetchAll() - while not working, foreach works(php PDO fetchAll() - 雖然不工作,但 foreach 工作)
        • <i id='LmKIs'><tr id='LmKIs'><dt id='LmKIs'><q id='LmKIs'><span id='LmKIs'><b id='LmKIs'><form id='LmKIs'><ins id='LmKIs'></ins><ul id='LmKIs'></ul><sub id='LmKIs'></sub></form><legend id='LmKIs'></legend><bdo id='LmKIs'><pre id='LmKIs'><center id='LmKIs'></center></pre></bdo></b><th id='LmKIs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LmKIs'><tfoot id='LmKIs'></tfoot><dl id='LmKIs'><fieldset id='LmKIs'></fieldset></dl></div>

              <bdo id='LmKIs'></bdo><ul id='LmKIs'></ul>
              <legend id='LmKIs'><style id='LmKIs'><dir id='LmKIs'><q id='LmKIs'></q></dir></style></legend>
                  <tbody id='LmKIs'></tbody>

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

                <tfoot id='LmKIs'></tfoot>
                  本文介紹了php PDO fetchAll() - 雖然不工作,但 foreach 工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想知道我是做得好還是 fetchAll() 不適用于 WHILE.

                  I would like to know if i'm doing fine OR fetchAll() doesn't work with WHILE.

                  舉個例子

                  $db=new PDO("mysql:host=" .$dbhost. "; dbname=" . $dbname, $dbuser, $dbpass);
                  
                  $page=$db->prepare("SELECT * FROM page");
                  $page->execute();
                  
                  foreach ($page->fetchAll(PDO::FETCH_ASSOC) as $row) {
                  
                  //echo a row
                  //is working
                  }
                  

                  但是,我如果嘗試使用 while 循環

                  however, i if try looping with a while

                  while ($row=$page->fetchAll(PDO::FETCH_ASSOC)){
                  
                  //echo a row
                  //Show empty
                  }
                  

                  我嘗試只使用 fetch(),它起作用了,我的問題是:為什么 fetchAll() 不能與WHILE"一起使用?

                  i tryed to use only fetch(), it was working, my question: why fetchAll() doesn't work with "WHILE" ?

                  推薦答案

                  Fetch all 返回結果集中剩余的所有記錄.考慮到這一點,您的 foreach 能夠按預期迭代結果集.

                  Fetch all returns all of the records remaining in the result set. With this in mind your foreach is able to iterate over the result set as expected.

                  對于等效的 while 實現應該使用 $page->fetch(PDO::FETCH_ASSOC);

                  For the equivalent while implementation should use $page->fetch(PDO::FETCH_ASSOC);

                  while ($row = $page->fetch(PDO::FETCH_ASSOC)){
                     // do something awesome with row
                  } 
                  

                  如果你想使用一段時間并獲取所有你能做的

                  if you want to use a while and fetch all you can do

                  $rows = $page->fetchAll(PDO::FETCH_ASSOC);
                  
                  // use array_shift to free up the memory associated with the record as we deal with it
                  while($row = array_shift($rows)){
                     // do something awesome with row
                  }
                  

                  盡管有一句警告:fetch all 將完全做到這一點,如果結果大小很大,則會對您機器上的資源造成壓力.只有在我知道結果集很小的情況下,我才會這樣做,或者我通過對查詢應用限制來強制這樣做.

                  A word of warning though: fetch all will do exactly that, if the result size is large it will stress the resources on your machine. I would only do this if I know that the result set will be small, or I'm forcing that by applying a limit to the query.

                  這篇關于php PDO fetchAll() - 雖然不工作,但 foreach 工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

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

                          <tfoot id='nCEPn'></tfoot>

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

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

                            主站蜘蛛池模板: av手机在线 | 国产视频2021 | a在线观看 | 国产一区二区三区四区hd | 国产精品亚洲精品日韩已方 | 亚洲交性 | 久久久xx | 中文字幕第十五页 | 能看的av| 99re在线视频| 久久久久91 | 亚洲精品一区二区在线观看 | 国产一区二区三区四区在线观看 | 亚洲欧美日本在线 | 久久伊| 久久久久久久一区 | av手机在线免费观看 | 国产xxxx岁13xxxxhd | 在线播放一区二区三区 | 日本大香伊一区二区三区 | 欧美久久久久 | 91亚洲国产成人久久精品网站 | 欧美在线a | 成人av电影免费在线观看 | 91在线网| 日韩欧美国产成人一区二区 | 亚洲综合二区 | 亚洲综合视频 | 久久精品视频一区二区三区 | 国产成人影院 | 久久久久国产成人精品亚洲午夜 | 国产亚洲黄色片 | 精品国产乱码久久久久久闺蜜 | 国产视频中文字幕 | 欧美aa在线| 亚洲日日 | 武道仙尊动漫在线观看 | 日韩一区二区三区精品 | 99热.com | 999精品在线| 久久成人午夜 |