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

    • <bdo id='ssxnF'></bdo><ul id='ssxnF'></ul>
    <tfoot id='ssxnF'></tfoot>

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

        千篇一律的foreach優化

        Optimization of foreach for thousands items(千篇一律的foreach優化)
        <legend id='LaXNd'><style id='LaXNd'><dir id='LaXNd'><q id='LaXNd'></q></dir></style></legend>

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

                <tbody id='LaXNd'></tbody>
            3. <tfoot id='LaXNd'></tfoot>
                <bdo id='LaXNd'></bdo><ul id='LaXNd'></ul>

                  本文介紹了千篇一律的foreach優化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在對一組 25,000 結果運行下面的代碼.我需要優化它,因為我達到了內存限制.

                  I'm running the code below over a set of 25,000 results. I need to optimize it because i'm hitting the memory limit.

                  $oldproducts = Oldproduct::model()->findAll(); /*(here i have 25,000 results)*/
                  
                  foreach($oldproducts as $oldproduct) :
                      $criteria = new CDbCriteria;
                      $criteria->compare('`someid`', $oldproduct->someid);
                      $finds = Newproduct::model()->findAll($criteria);
                  
                      if (empty($finds)) {
                          $new = new Newproduct;
                          $new->someid = $oldproduct->someid;
                          $new->save();
                      } else {
                          foreach($finds as $find) :
                              if ($find->price != $oldproduct->price) {
                                  $find->attributes=array('price' => $oldproduct->price);
                                  $find->save();
                              }
                          endforeach;
                      }
                  endforeach;
                  

                  代碼通過someid比較兩個表的行.如果發現巧合,它會更新 price 列,否則會創建一個新記錄.

                  Code compares rows of two tables by someid. If it find coincidence it updates price column, if not creates a new record.

                  推薦答案

                  使用 CDataProviderIterator 其中:

                  Use CDataProviderIterator which:

                  ... 允許對大型數據集進行迭代,而無需將整個數據集保存在內存中.

                  ... allows iteration over large data sets without holding the entire set in memory.

                  您首先必須將 CDataProvider 實例傳遞給它:

                  You first have to pass a CDataProvider instance to it:

                  $dataProvider = new CActiveDataProvider("Oldproduct");
                  $iterator = new CDataProviderIterator($dataProvider);
                  foreach($iterator as $item) {
                      // do stuff
                  }
                  

                  這篇關于千篇一律的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的訪問被拒絕)
                      <tbody id='Rvw48'></tbody>
                  • <i id='Rvw48'><tr id='Rvw48'><dt id='Rvw48'><q id='Rvw48'><span id='Rvw48'><b id='Rvw48'><form id='Rvw48'><ins id='Rvw48'></ins><ul id='Rvw48'></ul><sub id='Rvw48'></sub></form><legend id='Rvw48'></legend><bdo id='Rvw48'><pre id='Rvw48'><center id='Rvw48'></center></pre></bdo></b><th id='Rvw48'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Rvw48'><tfoot id='Rvw48'></tfoot><dl id='Rvw48'><fieldset id='Rvw48'></fieldset></dl></div>

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

                        1. <tfoot id='Rvw48'></tfoot>
                          • <bdo id='Rvw48'></bdo><ul id='Rvw48'></ul>
                            <legend id='Rvw48'><style id='Rvw48'><dir id='Rvw48'><q id='Rvw48'></q></dir></style></legend>
                            主站蜘蛛池模板: 亚洲电影在线播放 | 亚洲一区中文字幕 | 黄色免费看 | 99精品免费视频 | 久久久国产精品一区 | 亚洲国产精品区 | 91精品国产综合久久小仙女图片 | 中文字幕综合 | 精品伊人 | 在线观看你懂的网站 | 精品在线一区 | 免费成人在线网站 | 日韩不卡视频在线 | 超碰在线国产 | 欧美激情在线观看一区二区三区 | 亚洲天堂一区二区 | 91综合在线观看 | 国产成人久久av免费高清密臂 | 国产成人免费视频 | 国产国产精品久久久久 | 久草在线影 | 日韩中文一区二区三区 | 亚洲一区二区三区 | 成人在线免费网站 | zzzwww在线看片免费 | h在线观看| 久久精品国产免费看久久精品 | 欧美日韩国产高清 | 国产精品视频观看 | 91久久爽久久爽爽久久片 | 四虎海外| 在线观看国产91 | 亚洲综合在线网 | 国产精品国产成人国产三级 | 日韩精品久久久 | 国产欧美精品一区二区三区 | 五月婷婷在线视频 | 久草院线 | 中日韩欧美一级片 | 久久不卡日韩美女 | 成人在线观看欧美 |