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

                            主站蜘蛛池模板: 欧美在线视频免费观看 | 天天操天天碰 | 久草青青草 | 久久精品毛片 | 少妇福利视频 | 性久久久久久 | 911精品国产一区二区在线 | 日韩精品福利 | 热久久久久 | 精品欧美一区二区三区久久久 | 青青视频网 | 色视频www在线播放国产人成 | 日韩欧美国产成人 | 福利视频一区二区 | xxxxx国产 | 四虎成人在线 | 国产毛片一级 | 国产成人精品一区二区三区四区 | 激情久久久久 | 日韩网站免费观看 | 天天综合av | 日本少妇中文字幕 | 亚洲欧美一区二区三区在线 | 日韩中文字幕在线视频 | 韩日一级片 | 天天插天天干 | 91在线精品秘密一区二区 | 伊人综合影院 | 亚洲精品一区二区三区在线 | 男女啪啪无遮挡 | 激情久久五月天 | 九九热免费视频 | 午夜av在线播放 | 能看的av网站 | 亚洲视频在线看 | a级片免费| 中文在线观看免费视频 | 视频一二区 | 国产69精品久久久久久 | 国产精品久久久一区二区三区 | 高清免费av|