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

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

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

    1. <legend id='y7s1A'><style id='y7s1A'><dir id='y7s1A'><q id='y7s1A'></q></dir></style></legend>

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

        如何在沒有 FETCHALL 的情況下在 MYSQL PDO 中獲取

        How to fetch 2 times in MYSQL PDO without FETCHALL(如何在沒有 FETCHALL 的情況下在 MYSQL PDO 中獲取 2 次)

            • <bdo id='xB5l0'></bdo><ul id='xB5l0'></ul>
                <tbody id='xB5l0'></tbody>
              <tfoot id='xB5l0'></tfoot>
            • <legend id='xB5l0'><style id='xB5l0'><dir id='xB5l0'><q id='xB5l0'></q></dir></style></legend>

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

                  <i id='xB5l0'><tr id='xB5l0'><dt id='xB5l0'><q id='xB5l0'><span id='xB5l0'><b id='xB5l0'><form id='xB5l0'><ins id='xB5l0'></ins><ul id='xB5l0'></ul><sub id='xB5l0'></sub></form><legend id='xB5l0'></legend><bdo id='xB5l0'><pre id='xB5l0'><center id='xB5l0'></center></pre></bdo></b><th id='xB5l0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xB5l0'><tfoot id='xB5l0'></tfoot><dl id='xB5l0'><fieldset id='xB5l0'></fieldset></dl></div>
                1. 本文介紹了如何在沒有 FETCHALL 的情況下在 MYSQL PDO 中獲取 2 次的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有這個示例查詢:

                  $STH = $DBH->query("SELECT id FROM table");
                  

                  我想獲取第一行,然后循環顯示所有行.所以我使用以下內容來獲取第一行:

                  I want to get the first row and then loop and display all rows. So I use the following to get the first row:

                  $STH->setFetchMode(PDO::FETCH_ASSOC);
                  $first_row = $STH->fetch();
                  $first_row = $first_row['id'];
                  

                  我使用 while 循環再次顯示所有行:

                  I use while loop to display all rows again:

                  while ($list = $STH->fetch()) {      
                  $id = $list['id'];
                  echo $id;
                  }
                  

                  現在 while 跳過第一行,我希望它被顯示.是否有等效于 mysql_data_seek 將指針再次重置到第一行?我知道 fetchall 可以使用,但它對內存很不利,而且很浪費.我也可以運行查詢并限制為 1,但不建議這樣做,因為我有一個連接多個表的查詢,并且速度非常慢.還有其他解決辦法嗎?

                  Now the while skips the first row and I want it to be displayed. Is there an equivalent to mysql_data_seek to reset the pointer again to the first row? I know fetchall can be used but it's bad on memory and wasteful. I could also run the query and limit to 1 but this is not recommended as I have a query that joins multiple tables and would be very slow. Is there any other solution?

                  謝謝

                  推薦答案

                  我認為你可以使用光標方向常量來選擇結果......示例代碼即將推出......我還沒有嘗試過,所以你可以需要玩一會兒.這也是基于這樣一個假設:PDO::FETCH_ORI_FIRST 的作用類似于 data_seek,并將光標留在第一個位置,而不是將其返回到之前的位置.

                  I take that back looks like you can use the cursor orientation contants to select the result... sample code coming... I havent tried this so you may need to play a bit. This is also based on the assumption that a PDO::FETCH_ORI_FIRST acts like a data_seek and leaves the cursor on the first position as opposed to returning it to whatever it was before.

                  $stmt = $pdo->prepare('SELECT id FROM table', array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
                  $stmt->execute();
                  
                  $first = $pdo->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_FIRST);
                  $first_row = $first['id'];
                  
                  // other stuff
                  
                  // first iteration we rewind to the first record;
                  $cursor = PDO::FETCH_ORI_FIRST;
                  
                  while (false !== ($row = $stmt->fetch(PDO::FETCH_ASSOC, $cursor))) {
                     $id = $row['id'];
                     // successive iterations we hit the "next" record
                     $cursor = PDO::FETCH_ORI_NEXT; 
                     echo $id;
                  }
                  

                  <小時>

                  我不認為你可以倒帶一個語句......假設這些塊沒有被一堆中間邏輯 id 分開,只需在循環中進行即可.


                  I dont think you can rewind a statement... Assuming these blocks arent seprated by a bunch of intermediary logic id just do it in the loop.

                  $STH->setFetchMode(PDO::FETCH_COLUMN); // no need to pull an array
                  $count = 0;
                  while ($id = $STH->fetch()) {      
                    if($count === 0) {
                     $first_row = $id;
                    }
                    echo $id;
                    $count++;
                  }
                  

                  這篇關于如何在沒有 FETCHALL 的情況下在 MYSQL PDO 中獲取 2 次的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='mhJ9W'></small><noframes id='mhJ9W'>

                    <tbody id='mhJ9W'></tbody>
                2. <tfoot id='mhJ9W'></tfoot><legend id='mhJ9W'><style id='mhJ9W'><dir id='mhJ9W'><q id='mhJ9W'></q></dir></style></legend>

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

                          1. 主站蜘蛛池模板: 国产一区在线免费观看 | 国产在线高清 | 久久99精品久久久久久 | 国产成人精品一区 | 亚洲高清视频一区二区 | 一级一级一级毛片 | 久久久国产精品 | 日本黄色高清视频 | 亚洲小视频在线观看 | 欧美性受xxxx | 91视频精选 | 亚洲精品9999 | 特级黄一级播放 | 成人性视频免费网站 | 中文一区二区 | 亚洲视频免费 | 国产精品免费av | 青青草综合 | 午夜视频在线观看一区二区 | 久久九| 国产一区二区三区四区 | 伊人av在线播放 | 91九色视频在线 | 欧美精品一二三 | www.久久.com| 综合色播| 黄色毛片一级 | 国产精品jizz在线观看老狼 | 粉嫩av久久一区二区三区 | 久久久久久国产精品久久 | 99国产精品久久久久 | 亚州无限乱码 | 精品国产一区二区在线 | 中文字幕在线一区二区三区 | 国产999在线观看 | 鸳鸯谱在线观看高清 | 精品一二三区视频 | 婷婷丁香在线视频 | 欧美日韩精品一区 | 在线欧美日韩 | 中文字幕一区二区三区精彩视频 |