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

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

        <bdo id='3pTFZ'></bdo><ul id='3pTFZ'></ul>
        <legend id='3pTFZ'><style id='3pTFZ'><dir id='3pTFZ'><q id='3pTFZ'></q></dir></style></legend>
      1. <small id='3pTFZ'></small><noframes id='3pTFZ'>

        <tfoot id='3pTFZ'></tfoot>

      2. PDO fetchAll() 主鍵作為數組組鍵

        PDO fetchAll() primary key as array group key(PDO fetchAll() 主鍵作為數組組鍵)
        • <bdo id='hHHsx'></bdo><ul id='hHHsx'></ul>
            <tbody id='hHHsx'></tbody>

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

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

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

                  <tfoot id='hHHsx'></tfoot>
                1. 本文介紹了PDO fetchAll() 主鍵作為數組組鍵的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想將特定數據庫的內容存儲到按主鍵分組的數組中.(而不是 PDO fetchAll() 組織它們的無用方式).

                  I want to store the contents of a specific database into an array, grouped by their primary keys. (Instead of the useless way PDO fetchAll() organises them).

                  我當前的代碼:

                  $DownloadsPDO = $database->dbh->prepare("SELECT * FROM `downloads`");
                  $DownloadsArray =  $DownloadsPDO->execute();
                  $DownloadsArray =  $DownloadsPDO->fetchAll();
                  

                  然后輸出:

                  Array ( [0] => Array ( [id] => 0 [0] => 0 [path] => /xx-xx/testfile.zip [1] => /xx-xx/testfile.zip [name] => Test Script [2] => Test Script [status] => 1 [3] => 1 ) [1] => Array ( [id] => 1 [0] => 1 [path] => /xx-xx/test--file.zip [1] => /xxxx/testfile.zip [name] => New Script-UPDATE [2] => New Script-UPDATE [status] => 1 [3] => 1 ) )
                  

                  我曾考慮使用 PDO::FETCH_PAIR,但是我很快就會擴展我希望能夠在此腳本上使用的數據量.這目前有效,但是當我開始擴大下載量并且更多客戶端開始使用時,顯然數據的分組方式會導致問題.

                  I was considering to use PDO::FETCH_PAIR, however I will be very soon expanding the amount of data I want to be able to use on this script. This works currently, but when I start to expand the amount of downloads and more clients come into play, obviously the way the data is grouped causes an issue.

                  我可以按主鍵(即 id)對每個數組進行分組嗎?

                  Is it possible for me to group each array by their primary key (which is id)?

                  推薦答案

                  我決定用 fetch() 循環遍歷結果,然后將它們輸入到一個數組中,這是我使用過的代碼并且它有效就好了:

                  I decided to just loop through the results with fetch() and enter them into an array as I go along, this is the code I have used and it works just fine:

                  $DownloadsPDO = $database->dbh->query("SELECT * FROM `downloads`");
                  $Array = array();
                  while ($d = $DownloadsPDO->fetch()) {
                      $Array[$d['id']]["id"] = $d['id'];
                      $Array[$d['id']]["name"] = $d['name'];
                      $Array[$d['id']]["path"] = $d['path'];                          
                  }
                  
                  // Outputs
                  Array ( [1] => Array ( [id] => 1 [name] => Test Script [path] => /xxxx/testfile.zip ) [2] => Array ( [id] => 2 [name] => New Script-UPDATE [path] => /xxxx/testfile.zip ) ) 
                  

                  它使用主鍵(即id)作為數組鍵的名稱,然后將數據添加到其中.

                  Which uses the primary key (being id) as the name for the array key, and then adds the data into it.

                  我想我會添加這個作為答案,因為這解決了它,感謝提供幫助的人,我希望這對希望實現相同目標的其他人有所幫助.

                  Thought I would add this as the answer as this solved it, thanks to the guys that helped out and I hope this is helpful to anyone else hoping to achieve the same thing.

                  這篇關于PDO fetchAll() 主鍵作為數組組鍵的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                    <i id='pTy9e'><tr id='pTy9e'><dt id='pTy9e'><q id='pTy9e'><span id='pTy9e'><b id='pTy9e'><form id='pTy9e'><ins id='pTy9e'></ins><ul id='pTy9e'></ul><sub id='pTy9e'></sub></form><legend id='pTy9e'></legend><bdo id='pTy9e'><pre id='pTy9e'><center id='pTy9e'></center></pre></bdo></b><th id='pTy9e'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pTy9e'><tfoot id='pTy9e'></tfoot><dl id='pTy9e'><fieldset id='pTy9e'></fieldset></dl></div>
                    • <bdo id='pTy9e'></bdo><ul id='pTy9e'></ul>
                    • <legend id='pTy9e'><style id='pTy9e'><dir id='pTy9e'><q id='pTy9e'></q></dir></style></legend>
                        <tbody id='pTy9e'></tbody>

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

                          • <tfoot id='pTy9e'></tfoot>
                            主站蜘蛛池模板: 九九九精品视频 | 国产电影一区二区 | 成人av一区二区三区 | 亚洲一区av在线 | 三级成人在线观看 | 综合一区二区三区 | 午夜三级视频 | 久草网站 | 97国产精品视频人人做人人爱 | 久久99精品久久久久久琪琪 | 国产视频一区二区 | 欧美一区二区三区免费在线观看 | 狠狠撸在线视频 | 天堂av在线影院 | 国产一区91精品张津瑜 | 久草免费在线视频 | 国产在线观看一区二区三区 | 欧美日韩亚洲二区 | 日韩精品久久久久久 | 精品成人佐山爱一区二区 | 国产精品精品视频一区二区三区 | 亚洲国产精品一区二区久久 | 亚洲一区二区三区乱码aⅴ 四虎在线视频 | 国产精品一区二区在线免费观看 | 亚洲精品久久久9婷婷中文字幕 | 国产亚洲欧美日韩精品一区二区三区 | 91精品国产自产精品男人的天堂 | 精品福利视频一区二区三区 | 国产成人精品区一区二区不卡 | 黄网站免费在线看 | 国产精品久久久久久吹潮 | 99爱在线免费观看 | 免费看黄视频网站 | 天天碰日日操 | 日韩精品视频网 | 久久久久久久久99精品 | 亚州成人 | a免费观看 | 视频在线一区二区 | 色片在线观看 | 爱爱免费视频 |