Changeset 22590
- Timestamp:
- 2013/03/01 10:40:00 (11 years ago)
- Location:
- branches/version-2_12-dev/data/class
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php
r22581 r22590 343 343 $arrRet = $objQuery->select($col, $from, $where); 344 344 345 $arrParentID = SC_ Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);345 $arrParentID = SC_Utils_Ex::getTreeTrail($parent_category_id, 'category_id', 'parent_category_id', $arrRet); 346 346 347 347 foreach ($arrRet as $key => $array) { -
branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php
r22589 r22590 130 130 function lfGetCatTree($arrParentCategoryId, $count_check = false) 131 131 { 132 $objDb = new SC_Helper_DB_Ex();133 132 $objCategory = new SC_Helper_Category_Ex($count_check); 134 133 $arrTree = $objCategory->getTree(); … … 136 135 $arrCategory = $objCategory->getList(); 137 136 foreach ($arrParentCategoryId as $category_id) { 138 $arrParentID = $objDb->sfGetParents( 139 'dtb_category', 140 'parent_category_id', 141 'category_id', 142 $category_id 143 ); 137 $arrParentID = SC_Utils_Ex::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory); 144 138 $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray( 145 139 $arrCategory, -
branches/version-2_12-dev/data/class/util/SC_Utils.php
r22589 r22590 1933 1933 * @return array ツリーの配列 1934 1934 */ 1935 public static function buildTree($primary_key, $glue_key, $max_depth, $correction = array(), $ base_id = 0)1935 public static function buildTree($primary_key, $glue_key, $max_depth, $correction = array(), $root_id = 0) 1936 1936 { 1937 1937 $children = array(); … … 1939 1939 $children[$child[$glue_key]][] = $child; 1940 1940 } 1941 $arrTree = $children[$ base_id];1941 $arrTree = $children[$root_id]; 1942 1942 foreach ($arrTree as &$child) { 1943 1943 SC_Utils_Ex::addChild($child, $primary_key, 1, $max_depth, $children); … … 1985 1985 return $return; 1986 1986 } 1987 1988 /** 1989 * 階層情報が含まれている配列から親ID配列を取得する. 1990 * 1991 * @param integer $start_id 取得起点 1992 * @param string $primary_key 主キー名 1993 * @param string $glue_key 親IDキー名 1994 * @param array $correction 階層構造が含まれている配列 1995 * @param integer $root_id ルートID 1996 * @return array 親ID配列 1997 */ 1998 public static function getTreeTrail($start_id, $primary_key, $glue_key, $correction = array(), $root_id = 0) 1999 { 2000 $arrIDToKay = SC_Utils_Ex::makeArrayIDToKey($primary_key, $correction); 2001 $id = $start_id; 2002 $arrTrail = array(); 2003 while ($id != $root_id && !SC_Utils_Ex::isBlank($id)) { 2004 $arrTrail[] = $id; 2005 if (isset($arrIDToKay[$id][$glue_key])) { 2006 $id = $arrIDToKay[$id][$glue_key]; 2007 } else { 2008 $id = $root_id; 2009 } 2010 } 2011 return array_reverse($arrTrail); 2012 } 1987 2013 }
Note: See TracChangeset
for help on using the changeset viewer.