Changeset 22594


Ignore:
Timestamp:
2013/03/01 21:52:02 (11 years ago)
Author:
pineray
Message:

#2166 static変数を使用してデータベースへのアクセスを減らす

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/helper/SC_Helper_Category.php

    r22589 r22594  
    5151    public function getList($cid_to_key = FALSE) 
    5252    { 
    53         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    54         $col = '*'; 
    55         $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; 
    56         // 登録商品数のチェック 
    57         if ($this->count_check) { 
    58             $where = 'del_flg = 0 AND product_count > 0'; 
    59         } else { 
    60             $where = 'del_flg = 0'; 
     53        static $arrCategory = array(); 
     54 
     55        if (!isset($arrCategory[$this->count_check])) { 
     56            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     57            $col = '*'; 
     58            $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; 
     59            // 登録商品数のチェック 
     60            if ($this->count_check) { 
     61                $where = 'del_flg = 0 AND product_count > 0'; 
     62            } else { 
     63                $where = 'del_flg = 0'; 
     64            } 
     65            $objQuery->setOption('ORDER BY rank DESC'); 
     66            $arrTmp = $objQuery->select($col, $from, $where); 
     67 
     68            $arrCategory[$this->count_check] = $arrTmp; 
    6169        } 
    62         $objQuery->setOption('ORDER BY rank DESC'); 
    63         $arrCategory = $objQuery->select($col, $from, $where); 
    6470 
    6571        if ($cid_to_key) { 
    6672            // 配列のキーをカテゴリーIDに 
    67             $arrCategory = SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory); 
     73            return SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory[$this->count_check]); 
    6874        } 
    69          
    70         return $arrCategory; 
     75 
     76        return $arrCategory[$this->count_check]; 
    7177    } 
    7278 
Note: See TracChangeset for help on using the changeset viewer.