久久久久久久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>
                            主站蜘蛛池模板: 亚洲精品国产电影 | 欧美色性| 欧美一区二区成人 | 91亚洲国产成人久久精品网站 | 91精品在线播放 | 亚洲精品专区 | 国产a视频 | 国产综合一区二区 | 午夜小视频在线观看 | 九九精品视频在线 | 国产精品日日摸夜夜添夜夜av | 国产电影一区二区在线观看 | 新91| 99精品电影 | 精产国产伦理一二三区 | 国产国产精品久久久久 | 久久国产精品亚洲 | 成人在线视频免费观看 | 91中文字幕在线观看 | 午夜精品在线观看 | 99热国产免费 | 国产精品美女久久久久aⅴ国产馆 | 波多野结衣精品在线 | 毛片大全 | 国产二区在线播放 | 国产高潮av| 99久久久国产精品免费消防器 | 99精品免费 | 久久久久国产精品免费免费搜索 | 中文字幕电影在线观看 | 在线免费看黄 | 欧美一区二区三区在线免费观看 | 在线观看第一页 | 欧美日韩国产传媒 | 国产成人精品免费视频 | 国产精品日日摸夜夜添夜夜av | 懂色av一区二区三区在线播放 | 99久久视频 | re久久 | 欧美日批| 91最新入口 |