久久久久久久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>

                            主站蜘蛛池模板: 91精品一区二区三区久久久久 | 欧美日韩在线免费 | 91精品国产91综合久久蜜臀 | 国产成人综合在线 | 91免费电影 | 羞羞视频在线网站观看 | 97av视频在线 | 日本不卡一区二区三区在线观看 | 亚洲日本免费 | 精品久久久久香蕉网 | 色婷婷久久久久swag精品 | 亚洲中午字幕 | 成人性生交大片免费看中文带字幕 | 亚洲成人高清 | 国产欧美日韩精品在线观看 | 午夜视频在线免费观看 | 综合久 | 国产精品久久久久久久7777 | 91精品国产综合久久久久 | 成人影视网址 | 正在播放国产精品 | 精品中文字幕视频 | 国产视频第一页 | 一本色道精品久久一区二区三区 | 亚洲精品久久久久久一区二区 | 欧美午夜视频 | 在线观看av网站永久 | 国产成人影院 | 午夜小影院 | 欧美精品一区二区三区在线播放 | 国产婷婷精品 | 国产一区二区三区视频 | 天天色av | 在线视频h| 日本欧美大片 | 一区二区三区中文字幕 | 久久久久亚洲 | 伊人热久久 | jav成人av免费播放 | 成人欧美一区二区三区在线观看 | 欧美日韩一区二区在线观看 |