Ignore:
Timestamp:
2013/05/02 18:11:36 (11 years ago)
Author:
h_yoshimoto
Message:

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

File:
1 edited

Legend:

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

    r22595 r22796  
    2929 * @version $Id:SC_Helper_DB.php 15532 2007-08-31 14:39:46Z nanasess $ 
    3030 */ 
    31 class SC_Helper_DB  
    32 { 
     31class SC_Helper_DB { 
    3332 
    3433    // {{{ properties 
     
    6564     *               引数 $add == false でカラムが存在しない場合 false 
    6665     */ 
    67     function sfColumnExists($table_name, $col_name, $col_type = '', $dsn = '', $add = false) 
    68     { 
     66    function sfColumnExists($table_name, $col_name, $col_type = '', $dsn = '', $add = false) { 
    6967        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    7068        $dsn = $dbFactory->getDSN($dsn); 
     
    104102     *               $add == false で, データが存在しない場合 false 
    105103     */ 
    106     function sfDataExists($table_name, $where, $arrWhereVal, $dsn = '', $sql = '', $add = false) 
    107     { 
     104    function sfDataExists($table_name, $where, $arrWhereVal, $dsn = '', $sql = '', $add = false) { 
    108105        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
    109106        $dsn = $dbFactory->getDSN($dsn); 
     
    134131     * @return array 店舗基本情報の配列 
    135132     */ 
    136     function sfGetBasisData($force = false, $col = '') 
    137     { 
     133    function sfGetBasisData($force = false, $col = '') { 
    138134        static $data = array(); 
    139135 
     
    157153 
    158154    /** 
    159      * 基本情報のキャッシュデータを取得する 
    160      * 
    161      * @param boolean $generate キャッシュファイルが無い時、DBのデータを基にキャッシュを生成するか 
    162      * @return array 店舗基本情報の配列 
    163      */ 
    164     function sfGetBasisDataCache($generate = false) 
    165     { 
    166         // テーブル名 
    167         $name = 'dtb_baseinfo'; 
    168         // キャッシュファイルパス 
    169         $filepath = MASTER_DATA_REALDIR . $name . '.serial'; 
    170         // ファイル存在確認 
    171         if (!file_exists($filepath) && $generate) { 
    172             // 存在していなければキャッシュ生成 
    173             $this->sfCreateBasisDataCache(); 
    174         } 
    175         // 戻り値初期化 
    176         $cacheData = array(); 
    177         // キャッシュファイルが存在すれば読み込む 
    178         if (file_exists($filepath)) { 
    179             // キャッシュデータファイルを読み込みアンシリアライズした配列を取得 
    180             $cacheData = unserialize(file_get_contents($filepath)); 
    181         } 
    182         // return 
    183         return $cacheData; 
    184     } 
    185  
    186     /** 
    187      * 基本情報のキャッシュデータファイルを生成する 
    188      * データはsfGetBasisDataより取得。 
    189      *  
    190      * このメソッドが直接呼ばれるのは、 
    191      *「基本情報管理>SHOPマスター」の更新完了後。 
    192      * sfGetBasisDataCacheでは、 
    193      * キャッシュデータファイルが無い場合に呼ばれます。 
    194      * 
    195      * @return bool キャッシュデータファイル生成結果 
    196      */ 
    197     function sfCreateBasisDataCache() 
    198     { 
    199         // テーブル名 
    200         $name = 'dtb_baseinfo'; 
    201         // キャッシュファイルパス 
    202         $filepath = MASTER_DATA_REALDIR . $name . '.serial'; 
    203         // データ取得 
    204         $arrData = $this->sfGetBasisData(true); 
    205         // シリアライズ 
    206         $data = serialize($arrData); 
    207         // ファイルを書き出しモードで開く 
    208         $handle = fopen($filepath, 'w'); 
    209         if (!$handle) { 
    210             // ファイル生成失敗 
    211             return false; 
    212         } 
    213         // ファイルの内容を書き出す. 
    214         $res = fwrite($handle, $data); 
    215         // ファイルを閉じる 
    216         fclose($handle); 
    217         if ( $res === false) { 
    218             // ファイル生成失敗 
    219             return false; 
    220         } 
    221         // ファイル生成成功 
    222         return true; 
    223     } 
    224  
    225     /** 
    226155     * 基本情報の登録数を取得する 
    227156     * 
     
    229158     * @deprecated 
    230159     */ 
    231     function sfGetBasisCount() 
    232     { 
     160    function sfGetBasisCount() { 
    233161        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    234162 
     
    241169     * @return boolean 有無 
    242170     */ 
    243     function sfGetBasisExists() 
    244     { 
     171    function sfGetBasisExists() { 
    245172        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    246173 
     
    249176 
    250177    /* 選択中のアイテムのルートカテゴリIDを取得する */ 
    251     function sfGetRootId() 
    252     { 
     178    function sfGetRootId() { 
    253179 
    254180        if (!$this->g_root_on) { 
     
    286212     * @return array オーダー前ポイントの配列 
    287213     */ 
    288     function sfGetRollbackPoint($order_id, $use_point, $add_point, $order_status) 
    289     { 
     214    function sfGetRollbackPoint($order_id, $use_point, $add_point, $order_status) { 
    290215        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    291216        $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', array($order_id)); 
     
    319244     * @return array カテゴリツリーの配列 
    320245     */ 
    321     function sfGetCatTree($parent_category_id, $count_check = false) 
    322     { 
     246    function sfGetCatTree($parent_category_id, $count_check = false) { 
    323247        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    324248        $col = ''; 
     
    343267        $arrRet = $objQuery->select($col, $from, $where); 
    344268 
    345         $arrParentID = SC_Utils_Ex::getTreeTrail($parent_category_id, 'category_id', 'parent_category_id', $arrRet); 
     269        $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    346270 
    347271        foreach ($arrRet as $key => $array) { 
     
    366290     * @see sfGetCatTree() 
    367291     */ 
    368     function findTree(&$arrTree, $parent, &$result) 
    369     { 
     292    function findTree(&$arrTree, $parent, &$result) { 
    370293        if ($result[count($result) - 1]['parent_category_id'] === 0) { 
    371294            return; 
     
    391314     * @return array カテゴリツリーの配列 
    392315     */ 
    393     function sfGetMultiCatTree($product_id, $count_check = false) 
    394     { 
     316    function sfGetMultiCatTree($product_id, $count_check = false) { 
    395317        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    396318        $col = ''; 
     
    440362     * @return string 親カテゴリを連結した文字列 
    441363     */ 
    442     function sfGetCatCombName($category_id) 
    443     { 
     364    function sfGetCatCombName($category_id) { 
    444365        // 商品が属するカテゴリIDを縦に取得 
    445366        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    461382 
    462383    /** 
     384     * 指定したカテゴリIDのカテゴリを取得する. 
     385     * 
     386     * @param integer $category_id カテゴリID 
     387     * @return array 指定したカテゴリIDのカテゴリ 
     388     */ 
     389    function sfGetCat($category_id) { 
     390        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     391 
     392        // カテゴリを取得する 
     393        $arrVal = array($category_id); 
     394        $res = $objQuery->select('category_id AS id, category_name AS name', 'dtb_category', 'category_id = ?', $arrVal); 
     395 
     396        return $res[0]; 
     397    } 
     398 
     399    /** 
    463400     * 指定したカテゴリIDの大カテゴリを取得する. 
    464401     * 
     
    466403     * @return array 指定したカテゴリIDの大カテゴリ 
    467404     */ 
    468     function sfGetFirstCat($category_id) 
    469     { 
     405    function sfGetFirstCat($category_id) { 
    470406        // 商品が属するカテゴリIDを縦に取得 
    471407        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    492428     * @return array カテゴリツリーの配列 
    493429     */ 
    494     function sfGetCategoryList($addwhere = '', $products_check = false, $head = CATEGORY_HEAD) 
    495     { 
     430    function sfGetCategoryList($addwhere = '', $products_check = false, $head = CATEGORY_HEAD) { 
    496431        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    497432        $where = 'del_flg = 0'; 
     
    532467     * @return array カテゴリツリーの配列 
    533468     */ 
    534     function sfGetLevelCatList($parent_zero = true) 
    535     { 
     469    function sfGetLevelCatList($parent_zero = true) { 
    536470        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    537471 
     
    582516     * 
    583517     */ 
    584     function sfGetCategoryId($product_id, $category_id = 0, $closed = false) 
    585     { 
     518    function sfGetCategoryId($product_id, $category_id = 0, $closed = false) { 
    586519        if ($closed) { 
    587520            $status = ''; 
     
    610543     * @return void 
    611544     */ 
    612     function addProductBeforCategories($category_id, $product_id) 
    613     { 
     545    function addProductBeforCategories($category_id, $product_id) { 
    614546        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    615547 
     
    632564     * @return void 
    633565     */ 
    634     function addProductAfterCategories($category_id, $product_id) 
    635     { 
     566    function addProductAfterCategories($category_id, $product_id) { 
    636567        $sqlval = array('category_id' => $category_id, 
    637568                        'product_id' => $product_id); 
     
    665596     * @return void 
    666597     */ 
    667     function removeProductByCategories($category_id, $product_id) 
    668     { 
     598    function removeProductByCategories($category_id, $product_id) { 
    669599        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    670600        $objQuery->delete('dtb_product_categories', 
     
    679609     * @return void 
    680610     */ 
    681     function updateProductCategories($arrCategory_id, $product_id) 
    682     { 
     611    function updateProductCategories($arrCategory_id, $product_id) { 
    683612        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    684613 
     
    713642     * @return void 
    714643     */ 
    715     function sfCountCategory($objQuery = NULL, $is_force_all_count = false) 
    716     { 
     644    function sfCountCategory($objQuery = NULL, $is_force_all_count = false) { 
    717645        $objProduct = new SC_Product_Ex(); 
    718646 
     
    891819     * @param array 子ID の配列 
    892820     */ 
    893     function sfGetChildsID($table, $pid_name, $id_name, $id) 
    894     { 
     821    function sfGetChildsID($table, $pid_name, $id_name, $id) { 
    895822        $arrRet = $this->sfGetChildrenArray($table, $pid_name, $id_name, $id); 
    896823        return $arrRet; 
     
    906833     * @return array 子IDの配列 
    907834     */ 
    908     function sfGetChildrenArray($table, $pid_name, $id_name, $id) 
    909     { 
     835    function sfGetChildrenArray($table, $pid_name, $id_name, $id) { 
    910836        $arrChildren = array(); 
    911837        $arrRet = array($id); 
     
    928854     * @return array 子IDの配列 
    929855     */ 
    930     function sfGetChildrenArraySub($table, $pid_name, $id_name, $arrPID) 
    931     { 
     856    function sfGetChildrenArraySub($table, $pid_name, $id_name, $arrPID) { 
    932857        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    933858 
     
    949874     * @return array 親IDの配列 
    950875     */ 
    951     function sfGetParents($table, $pid_name, $id_name, $id) 
    952     { 
     876    function sfGetParents($table, $pid_name, $id_name, $id) { 
    953877        $arrRet = SC_Helper_DB_Ex::sfGetParentsArray($table, $pid_name, $id_name, $id); 
    954878        return $arrRet; 
     
    964888     * @return array 親IDの配列 
    965889     */ 
    966     function sfGetParentsArray($table, $pid_name, $id_name, $id) 
    967     { 
     890    function sfGetParentsArray($table, $pid_name, $id_name, $id) { 
    968891        $arrParents = array(); 
    969892        $ret = $id; 
     
    980903 
    981904    /* 子ID所属する親IDを取得する */ 
    982     function sfGetParentsArraySub($table, $pid_name, $id_name, $child) 
    983     { 
     905    function sfGetParentsArraySub($table, $pid_name, $id_name, $child) { 
    984906        if (SC_Utils_Ex::isBlank($child)) { 
    985907            return false; 
     
    999921     * @return array 商品を検索する場合の配列 
    1000922     */ 
    1001     function sfGetCatWhere($category_id) 
    1002     { 
     923    function sfGetCatWhere($category_id) { 
    1003924        // 子カテゴリIDの取得 
    1004925        $arrRet = SC_Helper_DB_Ex::sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $category_id); 
     
    1019940     * @return array SELECT ボックス用リストの配列 
    1020941     */ 
    1021     function sfGetIDValueList($table, $keyname, $valname, $where = '', $arrVal = array()) 
    1022     { 
     942    function sfGetIDValueList($table, $keyname, $valname, $where = '', $arrVal = array()) { 
    1023943        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    1024944        $col = "$keyname, $valname"; 
     
    1045965     * @return void 
    1046966     */ 
    1047     function sfRankUp($table, $colname, $id, $andwhere = '') 
    1048     { 
     967    function sfRankUp($table, $colname, $id, $andwhere = '') { 
    1049968        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    1050969        $objQuery->begin(); 
     
    10971016     * @return void 
    10981017     */ 
    1099     function sfRankDown($table, $colname, $id, $andwhere = '') 
    1100     { 
     1018    function sfRankDown($table, $colname, $id, $andwhere = '') { 
    11011019        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    11021020        $objQuery->begin(); 
     
    11491067     * @return void 
    11501068     */ 
    1151     function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') 
    1152     { 
     1069    function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') { 
    11531070        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    11541071        $objQuery->begin(); 
     
    12771194     * @return array 特定のカラムの配列 
    12781195     */ 
    1279     function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId) 
    1280     { 
     1196    function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId) { 
    12811197        $col = $col_name; 
    12821198        $len = count($arrId); 
     
    13101226     * @return void 
    13111227     */ 
    1312     function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) 
    1313     { 
     1228    function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { 
    13141229        if ($old_catid == $new_catid) { 
    13151230            return; 
     
    13501265     * @return bool レコードが存在する場合 true 
    13511266     */ 
    1352     function sfIsRecord($table, $col, $arrVal, $addwhere = '') 
    1353     { 
     1267    function sfIsRecord($table, $col, $arrVal, $addwhere = '') { 
    13541268        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    13551269        $arrCol = preg_split('/[, ]/', $col); 
     
    13841298     * @return void 
    13851299     */ 
    1386     function sfCountMaker($objQuery) 
    1387     { 
     1300    function sfCountMaker($objQuery) { 
    13881301        $sql = ''; 
    13891302 
     
    14091322     * 
    14101323     */ 
    1411     function sfGetMakerId($product_id, $maker_id = 0, $closed = false) 
    1412     { 
     1324    function sfGetMakerId($product_id, $maker_id = 0, $closed = false) { 
    14131325        if ($closed) { 
    14141326            $status = ''; 
     
    14441356     * @return array カテゴリツリーの配列 
    14451357     */ 
    1446     function sfGetMakerList($addwhere = '', $products_check = false) 
    1447     { 
     1358    function sfGetMakerList($addwhere = '', $products_check = false) { 
    14481359        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    14491360        $where = 'del_flg = 0'; 
     
    14821393     * @return integer 税金額 
    14831394     */ 
    1484     function sfTax($price) 
    1485     { 
     1395    function sfTax($price) { 
    14861396        // 店舗基本情報を取得 
    14871397        $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 
     
    14971407     * @return integer 税金付与した金額 
    14981408     */ 
    1499     function sfCalcIncTax($price, $tax = null, $tax_rule = null) 
    1500     { 
     1409    function sfCalcIncTax($price, $tax = null, $tax_rule = null) { 
    15011410        // 店舗基本情報を取得 
    15021411        $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 
    1503         $tax      = $tax      === null ? $CONF['tax']      : $tax; 
    1504         $tax_rule = $tax_rule === null ? $CONF['tax_rule'] : $tax_rule; 
    1505  
    1506         return SC_Utils_Ex::sfCalcIncTax($price, $tax, $tax_rule); 
     1412 
     1413        return SC_Utils_Ex::sfCalcIncTax($price, $CONF['tax'], $CONF['tax_rule']); 
    15071414    } 
    15081415 
     
    15141421     * @return integer 加算ポイント 
    15151422     */ 
    1516     function sfGetAddPoint($totalpoint, $use_point) 
    1517     { 
     1423    function sfGetAddPoint($totalpoint, $use_point) { 
    15181424        // 店舗基本情報を取得 
    15191425        $CONF = SC_Helper_DB_Ex::sfGetBasisData(); 
     
    15301436     * @return void 
    15311437     */ 
    1532     function sfExecSqlByFile($sqlFilePath) 
    1533     { 
     1438    function sfExecSqlByFile($sqlFilePath) { 
    15341439        if (file_exists($sqlFilePath)) { 
    15351440            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    15521457     * @return bool 商品規格が存在する場合:true, それ以外:false 
    15531458     */ 
    1554     function sfHasProductClass($product_id) 
    1555     { 
     1459    function sfHasProductClass($product_id) { 
    15561460        if (!SC_Utils_Ex::sfIsInt($product_id)) return false; 
    15571461 
     
    15621466        return $exists; 
    15631467    } 
    1564  
    1565     /** 
    1566      * 店舗基本情報を登録する 
    1567      * 
    1568      * @param array $arrData 登録するデータ 
    1569      * @return void 
    1570      */ 
    1571     static function registerBasisData($arrData) 
    1572     { 
    1573         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    1574  
    1575         $arrData = $objQuery->extractOnlyColsOf('dtb_baseinfo', $arrData); 
    1576  
    1577         if (isset($arrData['regular_holiday_ids']) && is_array($arrData['regular_holiday_ids'])) { 
    1578             // 定休日をパイプ区切りの文字列に変換 
    1579             $arrData['regular_holiday_ids'] = implode('|', $arrData['regular_holiday_ids']); 
    1580         } 
    1581  
    1582         $arrData['update_date'] = 'CURRENT_TIMESTAMP'; 
    1583  
    1584         // UPDATEの実行 
    1585         $ret = $objQuery->update('dtb_baseinfo', $arrData); 
    1586         GC_Utils_Ex::gfPrintLog('dtb_baseinfo に UPDATE を実行しました。'); 
    1587  
    1588         // UPDATE できなかった場合、INSERT 
    1589         if ($ret == 0) { 
    1590             $arrData['id'] = 1; 
    1591             $ret = $objQuery->insert('dtb_baseinfo', $arrData); 
    1592             GC_Utils_Ex::gfPrintLog('dtb_baseinfo に INSERT を実行しました。'); 
    1593         } 
    1594     } 
    1595  
    1596     /** 
    1597      * レコード件数を計算. 
    1598      *  
    1599      * @param string $table 
    1600      * @param string $where 
    1601      * @param array $arrval 
    1602      * @return integer レコード件数 
    1603      */ 
    1604     public function countRecords($table, $where = '', $arrval = array()) 
    1605     { 
    1606         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    1607         $col = 'COUNT(*)'; 
    1608         return $objQuery->get($col, $table, $where, $arrval); 
    1609     } 
    16101468} 
Note: See TracChangeset for help on using the changeset viewer.