Ignore:
Timestamp:
2007/08/24 12:52:51 (17 years ago)
Author:
nanasess
Message:

メソッド移動+未定義変数の修正

Location:
branches/feature-module-update/data/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/helper/SC_Helper_DB.php

    r15295 r15343  
    408408 
    409409    /** 
     410     * カテゴリツリーの取得を行う. 
     411     * 
     412     * $products_check:true商品登録済みのものだけ取得する 
     413     * 
     414     * @param string $addwhere 追加する WHERE 句 
     415     * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true 
     416     * @param string $head カテゴリ名のプレフィックス文字列 
     417     * @return array カテゴリツリーの配列 
     418     */ 
     419    function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { 
     420        $objQuery = new SC_Query(); 
     421        $where = "del_flg = 0"; 
     422 
     423        if($addwhere != "") { 
     424            $where.= " AND $addwhere"; 
     425        } 
     426 
     427        $objQuery->setoption("ORDER BY rank DESC"); 
     428 
     429        if($products_check) { 
     430            $col = "T1.category_id, category_name, level"; 
     431            $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; 
     432            $where .= " AND product_count > 0"; 
     433        } else { 
     434            $col = "category_id, category_name, level"; 
     435            $from = "dtb_category"; 
     436        } 
     437 
     438        $arrRet = $objQuery->select($col, $from, $where); 
     439 
     440        $max = count($arrRet); 
     441        for($cnt = 0; $cnt < $max; $cnt++) { 
     442            $id = $arrRet[$cnt]['category_id']; 
     443            $name = $arrRet[$cnt]['category_name']; 
     444            $arrList[$id] = ""; 
     445            /* 
     446            for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { 
     447                $arrList[$id].= " "; 
     448            } 
     449            */ 
     450            for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { 
     451                $arrList[$id].= $head; 
     452            } 
     453            $arrList[$id].= $name; 
     454        } 
     455        return $arrList; 
     456    } 
     457 
     458    /** 
     459     * カテゴリーツリーの取得を行う. 
     460     * 
     461     * 親カテゴリの Value=0 を対象とする 
     462     * 
     463     * @param bool $parent_zero 親カテゴリの Value=0 の場合 true 
     464     * @return array カテゴリツリーの配列 
     465     */ 
     466    function sfGetLevelCatList($parent_zero = true) { 
     467        $objQuery = new SC_Query(); 
     468        $col = "category_id, category_name, level"; 
     469        $where = "del_flg = 0"; 
     470        $objQuery->setoption("ORDER BY rank DESC"); 
     471        $arrRet = $objQuery->select($col, "dtb_category", $where); 
     472        $max = count($arrRet); 
     473 
     474        for($cnt = 0; $cnt < $max; $cnt++) { 
     475            if($parent_zero) { 
     476                if($arrRet[$cnt]['level'] == LEVEL_MAX) { 
     477                    $arrValue[$cnt] = $arrRet[$cnt]['category_id']; 
     478                } else { 
     479                    $arrValue[$cnt] = ""; 
     480                } 
     481            } else { 
     482                $arrValue[$cnt] = $arrRet[$cnt]['category_id']; 
     483            } 
     484 
     485            $arrOutput[$cnt] = ""; 
     486            /* 
     487            for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { 
     488                $arrOutput[$cnt].= " "; 
     489            } 
     490            */ 
     491            for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { 
     492                $arrOutput[$cnt].= CATEGORY_HEAD; 
     493            } 
     494            $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; 
     495        } 
     496        return array($arrValue, $arrOutput); 
     497    } 
     498 
     499    /** 
     500     * カテゴリ数の登録を行う. 
     501     * 
     502     * @param SC_Query $objQuery SC_Query インスタンス 
     503     * @return void 
     504     */ 
     505    function sfCategory_Count($objQuery){ 
     506        $sql = ""; 
     507 
     508        //テーブル内容の削除 
     509        $objQuery->query("DELETE FROM dtb_category_count"); 
     510        $objQuery->query("DELETE FROM dtb_category_total_count"); 
     511 
     512        //各カテゴリ内の商品数を数えて格納 
     513        $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; 
     514        $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; 
     515        $sql .= " ON T1.category_id = T2.category_id  "; 
     516        $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; 
     517        $sql .= " GROUP BY T1.category_id, T2.category_id "; 
     518        $objQuery->query($sql); 
     519 
     520        //子カテゴリ内の商品数を集計する 
     521        $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); 
     522 
     523        $sql = ""; 
     524        foreach($arrCat as $key => $val){ 
     525 
     526            // 子ID一覧を取得 
     527            $arrRet = $this->sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); 
     528            $line = SC_Utils_Ex::sfGetCommaList($arrRet); 
     529 
     530            $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; 
     531            $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; 
     532            $sql .= " WHERE category_id IN (" . $line . ")"; 
     533 
     534            $objQuery->query($sql, array($val['category_id'])); 
     535        } 
     536    } 
     537 
     538    /** 
     539     * 階層構造のテーブルから子ID配列を取得する. 
     540     * 
     541     * @param string $table テーブル名 
     542     * @param string $pid_name 親ID名 
     543     * @param string $id_name ID名 
     544     * @param integer $id ID番号 
     545     * @return array 子IDの配列 
     546     */ 
     547    function sfGetChildrenArray($table, $pid_name, $id_name, $id) { 
     548        $objQuery = new SC_Query(); 
     549        $col = $pid_name . "," . $id_name; 
     550         $arrData = $objQuery->select($col, $table); 
     551 
     552        $arrPID = array(); 
     553        $arrPID[] = $id; 
     554        $arrChildren = array(); 
     555        $arrChildren[] = $id; 
     556 
     557        $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); 
     558 
     559        while(count($arrRet) > 0) { 
     560            $arrChildren = array_merge($arrChildren, $arrRet); 
     561            $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); 
     562        } 
     563 
     564        return $arrChildren; 
     565    } 
     566 
     567    /** 
     568     * 親ID直下の子IDをすべて取得する. 
     569     * 
     570     * @param array $arrData 親カテゴリの配列 
     571     * @param string $pid_name 親ID名 
     572     * @param string $id_name ID名 
     573     * @param array $arrPID 親IDの配列 
     574     * @return array 子IDの配列 
     575     */ 
     576    function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { 
     577        $arrChildren = array(); 
     578        $max = count($arrData); 
     579 
     580        for($i = 0; $i < $max; $i++) { 
     581            foreach($arrPID as $val) { 
     582                if($arrData[$i][$pid_name] == $val) { 
     583                    $arrChildren[] = $arrData[$i][$id_name]; 
     584                } 
     585            } 
     586        } 
     587        return $arrChildren; 
     588    } 
     589 
     590    /** 
     591     * 階層構造のテーブルから親ID配列を取得する. 
     592     * 
     593     * @param string $table テーブル名 
     594     * @param string $pid_name 親ID名 
     595     * @param string $id_name ID名 
     596     * @param integer $id ID 
     597     * @return array 親IDの配列 
     598     */ 
     599    function sfGetParentsArray($table, $pid_name, $id_name, $id) { 
     600        $objQuery = new SC_Query(); 
     601        $col = $pid_name . "," . $id_name; 
     602         $arrData = $objQuery->select($col, $table); 
     603 
     604        $arrParents = array(); 
     605        $arrParents[] = $id; 
     606        $child = $id; 
     607 
     608        $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); 
     609 
     610        while($ret != "") { 
     611            $arrParents[] = $ret; 
     612            $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); 
     613        } 
     614 
     615        $arrParents = array_reverse($arrParents); 
     616 
     617        return $arrParents; 
     618    } 
     619 
     620    /** 
    410621     * 受注一時テーブルから情報を取得する. 
    411622     * 
  • branches/feature-module-update/data/class/util/SC_Utils.php

    r15340 r15343  
    453453        } 
    454454        for($i = 1; $i <= $max; $i++) { 
    455             if(isset($arrTmp) && $arrTmp[$i] == "1") { 
     455            if(isset($arrTmp[$i]) && $arrTmp[$i] == "1") { 
    456456                $ret.= "1"; 
    457457            } else { 
     
    705705    } 
    706706 
    707     // カテゴリツリーの取得($products_check:true商品登録済みのものだけ取得) 
    708     function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { 
    709         $objQuery = new SC_Query(); 
    710         $where = "del_flg = 0"; 
    711  
    712         if($addwhere != "") { 
    713             $where.= " AND $addwhere"; 
    714         } 
    715  
    716         $objQuery->setoption("ORDER BY rank DESC"); 
    717  
    718         if($products_check) { 
    719             $col = "T1.category_id, category_name, level"; 
    720             $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; 
    721             $where .= " AND product_count > 0"; 
    722         } else { 
    723             $col = "category_id, category_name, level"; 
    724             $from = "dtb_category"; 
    725         } 
    726  
    727         $arrRet = $objQuery->select($col, $from, $where); 
    728  
    729         $max = count($arrRet); 
    730         for($cnt = 0; $cnt < $max; $cnt++) { 
    731             $id = $arrRet[$cnt]['category_id']; 
    732             $name = $arrRet[$cnt]['category_name']; 
    733             $arrList[$id] = ""; 
    734             /* 
    735             for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { 
    736                 $arrList[$id].= " "; 
    737             } 
    738             */ 
    739             for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { 
    740                 $arrList[$id].= $head; 
    741             } 
    742             $arrList[$id].= $name; 
    743         } 
    744         return $arrList; 
    745     } 
    746  
    747     // カテゴリツリーの取得(親カテゴリのValue:0) 
    748     function sfGetLevelCatList($parent_zero = true) { 
    749         $objQuery = new SC_Query(); 
    750         $col = "category_id, category_name, level"; 
    751         $where = "del_flg = 0"; 
    752         $objQuery->setoption("ORDER BY rank DESC"); 
    753         $arrRet = $objQuery->select($col, "dtb_category", $where); 
    754         $max = count($arrRet); 
    755  
    756         for($cnt = 0; $cnt < $max; $cnt++) { 
    757             if($parent_zero) { 
    758                 if($arrRet[$cnt]['level'] == LEVEL_MAX) { 
    759                     $arrValue[$cnt] = $arrRet[$cnt]['category_id']; 
    760                 } else { 
    761                     $arrValue[$cnt] = ""; 
    762                 } 
    763             } else { 
    764                 $arrValue[$cnt] = $arrRet[$cnt]['category_id']; 
    765             } 
    766  
    767             $arrOutput[$cnt] = ""; 
    768             /* 
    769             for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { 
    770                 $arrOutput[$cnt].= " "; 
    771             } 
    772             */ 
    773             for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { 
    774                 $arrOutput[$cnt].= CATEGORY_HEAD; 
    775             } 
    776             $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; 
    777         } 
    778         return array($arrValue, $arrOutput); 
    779     } 
    780  
    781707    function sfGetErrorColor($val) { 
    782708        if($val != "") { 
     
    785711        return ""; 
    786712    } 
    787  
    788713 
    789714    function sfGetEnabled($val) { 
     
    998923            $where = "product_id = ?"; 
    999924            $objQuery->delete("dtb_products_class", $where, array($product_id)); 
     925 
     926            // 配列の添字を定義 
     927            $checkArray = array("product_code", "stock", "stock_unlimited", "price01", "price02"); 
     928            $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); 
     929 
    1000930            $sqlval['product_id'] = $product_id; 
    1001931            $sqlval['classcategory_id1'] = '0'; 
     
    14321362            $category_id = (int) $category_id; 
    14331363            $product_id = (int) $product_id; 
    1434             if(SC_Utils_Ex::sfIsInt($category_id) && SC_Utils_Ex::sfIsRecord("dtb_category","category_id", $category_id)) { 
     1364            $objDb = new SC_Helper_DB_Ex(); 
     1365            if(SC_Utils_Ex::sfIsInt($category_id) && $objDb->sfIsRecord("dtb_category","category_id", $category_id)) { 
    14351366                $g_category_id = $category_id; 
    1436             } else if (SC_Utils_Ex::sfIsInt($product_id) && SC_Utils_Ex::sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { 
     1367            } else if (SC_Utils_Ex::sfIsInt($product_id) && $objDb->sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { 
    14371368                $objQuery = new SC_Query(); 
    14381369                $where = "product_id = ?"; 
     
    18131744        } 
    18141745 
    1815         if($_GET['tpl'] != "") { 
     1746        if(isset($_GET['tpl']) && $_GET['tpl'] != "") { 
    18161747            $tpl_name = $_GET['tpl']; 
    18171748        } else { 
     
    19031834    } 
    19041835 
    1905     function sfCategory_Count($objQuery){ 
    1906         $sql = ""; 
    1907  
    1908         //テーブル内容の削除 
    1909         $objQuery->query("DELETE FROM dtb_category_count"); 
    1910         $objQuery->query("DELETE FROM dtb_category_total_count"); 
    1911  
    1912         //各カテゴリ内の商品数を数えて格納 
    1913         $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; 
    1914         $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; 
    1915         $sql .= " ON T1.category_id = T2.category_id  "; 
    1916         $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; 
    1917         $sql .= " GROUP BY T1.category_id, T2.category_id "; 
    1918         $objQuery->query($sql); 
    1919  
    1920         //子カテゴリ内の商品数を集計する 
    1921         $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); 
    1922  
    1923         $sql = ""; 
    1924         foreach($arrCat as $key => $val){ 
    1925  
    1926             // 子ID一覧を取得 
    1927             $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); 
    1928             $line = sfGetCommaList($arrRet); 
    1929  
    1930             $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; 
    1931             $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; 
    1932             $sql .= " WHERE category_id IN (" . $line . ")"; 
    1933  
    1934             $objQuery->query($sql, array($val['category_id'])); 
    1935         } 
    1936     } 
    1937  
    19381836    // 2つの配列を用いて連想配列を作成する 
    19391837    function sfarrCombine($arrKeys, $arrValues) { 
     
    19521850 
    19531851        return false; 
    1954     } 
    1955  
    1956     /* 階層構造のテーブルから子ID配列を取得する */ 
    1957     function sfGetChildrenArray($table, $pid_name, $id_name, $id) { 
    1958         $objQuery = new SC_Query(); 
    1959         $col = $pid_name . "," . $id_name; 
    1960          $arrData = $objQuery->select($col, $table); 
    1961  
    1962         $arrPID = array(); 
    1963         $arrPID[] = $id; 
    1964         $arrChildren = array(); 
    1965         $arrChildren[] = $id; 
    1966  
    1967         $arrRet = SC_Utils::sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); 
    1968  
    1969         while(count($arrRet) > 0) { 
    1970             $arrChildren = array_merge($arrChildren, $arrRet); 
    1971             $arrRet = SC_Utils::sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); 
    1972         } 
    1973  
    1974         return $arrChildren; 
    1975     } 
    1976  
    1977     /* 親ID直下の子IDをすべて取得する */ 
    1978     function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { 
    1979         $arrChildren = array(); 
    1980         $max = count($arrData); 
    1981  
    1982         for($i = 0; $i < $max; $i++) { 
    1983             foreach($arrPID as $val) { 
    1984                 if($arrData[$i][$pid_name] == $val) { 
    1985                     $arrChildren[] = $arrData[$i][$id_name]; 
    1986                 } 
    1987             } 
    1988         } 
    1989         return $arrChildren; 
    1990     } 
    1991  
    1992  
    1993     /* 階層構造のテーブルから親ID配列を取得する */ 
    1994     function sfGetParentsArray($table, $pid_name, $id_name, $id) { 
    1995         $objQuery = new SC_Query(); 
    1996         $col = $pid_name . "," . $id_name; 
    1997          $arrData = $objQuery->select($col, $table); 
    1998  
    1999         $arrParents = array(); 
    2000         $arrParents[] = $id; 
    2001         $child = $id; 
    2002  
    2003         $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); 
    2004  
    2005         while($ret != "") { 
    2006             $arrParents[] = $ret; 
    2007             $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); 
    2008         } 
    2009  
    2010         $arrParents = array_reverse($arrParents); 
    2011  
    2012         return $arrParents; 
    20131852    } 
    20141853 
     
    23492188    } 
    23502189 
     2190    /** 
     2191     * 配列の添字が未定義の場合は空文字を代入して定義する. 
     2192     * 
     2193     * @param array $array 添字をチェックする配列 
     2194     * @param array $defineIndexes チェックする添字 
     2195     * @return array 添字を定義した配列 
     2196     */ 
     2197    function arrayDefineIndexes($array, $defineIndexes) { 
     2198        foreach ($defineIndexes as $key) { 
     2199            if (!isset($array[$key])) $array[$key] = ""; 
     2200        } 
     2201        return $array; 
     2202    } 
     2203 
    23512204    /* デバッグ用 ------------------------------------------------------------------------------------------------*/ 
    23522205    function sfPrintR($obj) { 
Note: See TracChangeset for help on using the changeset viewer.