Ignore:
Timestamp:
2014/05/29 14:40:57 (10 years ago)
Author:
pineray
Message:

#2515 無駄な処理を改善する for 2.13.3

カテゴリーID取得部分の処理を整理.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/SC_Product.php

    r23458 r23459  
    696696     */ 
    697697    public function getCategoryIds($product_id, $include_hidden = false) { 
    698         if ($include_hidden) { 
    699             $where = ''; 
    700         } else { 
    701             $where = 'status = 1'; 
    702         } 
    703  
    704         if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', array($product_id), $where)) { 
     698        if ($this->isValidProductId($product_id, $include_hidden)) { 
    705699            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    706700            $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); 
     
    712706        return $category_id; 
    713707    } 
     708 
     709    /** 
     710     * 有効な商品IDかチェックする. 
     711     * 
     712     * @param int $product_id 
     713     * @param bool $include_hidden 
     714     * @param bool $include_deleted 
     715     * @return bool 
     716     */ 
     717    public function isValidProductId($product_id, $include_hidden = false, $include_deleted = false) { 
     718        $where = ''; 
     719        if (!$include_hidden) { 
     720            $where .= ' status = 1'; 
     721        } 
     722        if (!$include_deleted) { 
     723            $where .= ' del_flg = 0'; 
     724        } 
     725        if ( 
     726            SC_Utils_Ex::sfIsInt($product_id) 
     727            && !SC_Utils_Ex::sfIsZeroFilling($product_id) 
     728            && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', array($product_id), $where) 
     729        ) { 
     730            return true; 
     731        } 
     732        return false; 
     733    } 
    714734} 
Note: See TracChangeset for help on using the changeset viewer.