Changeset 15364 for branches/feature-module-update/data/class
- Timestamp:
- 2007/08/27 16:31:19 (17 years ago)
- 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
r15359 r15364 22 22 /** ルートカテゴリID */ 23 23 var $g_root_id; 24 25 /** 選択中カテゴリ取得フラグ */ 26 var $g_category_on; 27 28 /** 選択中カテゴリID */ 29 var $g_category_id; 24 30 25 31 // }}} … … 205 211 if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) { 206 212 // 選択中のカテゴリIDを判定する 207 $category_id = SC_Utils_Ex::sfGetCategoryId($_GET['product_id'], $_GET['category_id']);213 $category_id = $this->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 208 214 // ROOTカテゴリIDの取得 209 $arrRet = SC_Utils_Ex::sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);215 $arrRet = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); 210 216 $root_id = $arrRet[0]; 211 217 } else { … … 420 426 * カテゴリツリーの取得を行う. 421 427 * 428 * @param integer $parent_category_id 親カテゴリID 429 * @param bool $count_check 登録商品数のチェックを行う場合 true 430 * @return array カテゴリツリーの配列 431 */ 432 function sfGetCatTree($parent_category_id, $count_check = false) { 433 $objQuery = new SC_Query(); 434 $col = ""; 435 $col .= " cat.category_id,"; 436 $col .= " cat.category_name,"; 437 $col .= " cat.parent_category_id,"; 438 $col .= " cat.level,"; 439 $col .= " cat.rank,"; 440 $col .= " cat.creator_id,"; 441 $col .= " cat.create_date,"; 442 $col .= " cat.update_date,"; 443 $col .= " cat.del_flg, "; 444 $col .= " ttl.product_count"; 445 $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; 446 // 登録商品数のチェック 447 if($count_check) { 448 $where = "del_flg = 0 AND product_count > 0"; 449 } else { 450 $where = "del_flg = 0"; 451 } 452 $objQuery->setoption("ORDER BY rank DESC"); 453 $arrRet = $objQuery->select($col, $from, $where); 454 455 $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 456 457 foreach($arrRet as $key => $array) { 458 foreach($arrParentID as $val) { 459 if($array['category_id'] == $val) { 460 $arrRet[$key]['display'] = 1; 461 break; 462 } 463 } 464 } 465 466 return $arrRet; 467 } 468 469 /** 470 * 親カテゴリーを連結した文字列を取得する. 471 * 472 * @param integer $category_id カテゴリID 473 * @return string 親カテゴリーを連結した文字列 474 */ 475 function sfGetCatCombName($category_id){ 476 // 商品が属するカテゴリIDを縦に取得 477 $objQuery = new SC_Query(); 478 $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); 479 $ConbName = ""; 480 481 // カテゴリー名称を取得する 482 foreach($arrCatID as $key => $val){ 483 $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; 484 $arrVal = array($val); 485 $CatName = $objQuery->getOne($sql,$arrVal); 486 $ConbName .= $CatName . ' | '; 487 } 488 // 最後の | をカットする 489 $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); 490 491 return $ConbName; 492 } 493 494 /** 495 * 指定したカテゴリーIDの大カテゴリーを取得する. 496 * 497 * @param integer $category_id カテゴリID 498 * @return array 指定したカテゴリーIDの大カテゴリー 499 */ 500 function sfGetFirstCat($category_id){ 501 // 商品が属するカテゴリIDを縦に取得 502 $objQuery = new SC_Query(); 503 $arrRet = array(); 504 $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); 505 $arrRet['id'] = $arrCatID[0]; 506 507 // カテゴリー名称を取得する 508 $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; 509 $arrVal = array($arrRet['id']); 510 $arrRet['name'] = $objQuery->getOne($sql,$arrVal); 511 512 return $arrRet; 513 } 514 515 /** 516 * カテゴリツリーの取得を行う. 517 * 422 518 * $products_check:true商品登録済みのものだけ取得する 423 519 * … … 508 604 509 605 /** 606 * 選択中のカテゴリを取得する. 607 * 608 * @param integer $product_id プロダクトID 609 * @param integer $category_id カテゴリID 610 * @return integer 選択中のカテゴリID 611 * 612 */ 613 function sfGetCategoryId($product_id, $category_id) { 614 615 if(!$this->g_category_on) { 616 $this->g_category_on = true; 617 $category_id = (int) $category_id; 618 $product_id = (int) $product_id; 619 if(SC_Utils_Ex::sfIsInt($category_id) && $this->sfIsRecord("dtb_category","category_id", $category_id)) { 620 $this->g_category_id = $category_id; 621 } else if (SC_Utils_Ex::sfIsInt($product_id) && $this->sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { 622 $objQuery = new SC_Query(); 623 $where = "product_id = ?"; 624 $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); 625 $this->g_category_id = $category_id; 626 } else { 627 // 不正な場合は、0を返す。 628 $this->g_category_id = 0; 629 } 630 } 631 return $this->g_category_id; 632 } 633 634 /** 510 635 * カテゴリ数の登録を行う. 511 636 * … … 623 748 */ 624 749 function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) { 625 $objDb = new SC_Helper_DB_Ex(); 626 $arrRet = $objDb->sfGetParentsArray($table, $pid_name, $id_name, $id); 750 $arrRet = $this->sfGetParentsArray($table, $pid_name, $id_name, $id); 627 751 // 配列の先頭1つを削除する。 628 752 array_shift($arrRet); -
branches/feature-module-update/data/class/util/SC_Utils.php
r15351 r15364 1346 1346 } 1347 1347 1348 // カテゴリID取得判定用のグローバル変数(一度取得されていたら再取得しないようにする)1349 //$g_category_on = false;1350 //$g_category_id = "";1351 1352 /* 選択中のカテゴリを取得する */1353 function sfGetCategoryId($product_id, $category_id) {1354 global $g_category_on;1355 global $g_category_id;1356 if(!$g_category_on) {1357 $g_category_on = true;1358 $category_id = (int) $category_id;1359 $product_id = (int) $product_id;1360 $objDb = new SC_Helper_DB_Ex();1361 if(SC_Utils_Ex::sfIsInt($category_id) && $objDb->sfIsRecord("dtb_category","category_id", $category_id)) {1362 $g_category_id = $category_id;1363 } else if (SC_Utils_Ex::sfIsInt($product_id) && $objDb->sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) {1364 $objQuery = new SC_Query();1365 $where = "product_id = ?";1366 $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id));1367 $g_category_id = $category_id;1368 } else {1369 // 不正な場合は、0を返す。1370 $g_category_id = 0;1371 }1372 }1373 return $g_category_id;1374 }1375 1376 1348 /* 加算ポイントの計算式 */ 1377 1349 function sfGetAddPoint($totalpoint, $use_point, $arrInfo) { … … 1879 1851 } 1880 1852 return $arrChildren; 1881 }1882 1883 1884 // カテゴリツリーの取得1885 function sfGetCatTree($parent_category_id, $count_check = false) {1886 $objQuery = new SC_Query();1887 $col = "";1888 $col .= " cat.category_id,";1889 $col .= " cat.category_name,";1890 $col .= " cat.parent_category_id,";1891 $col .= " cat.level,";1892 $col .= " cat.rank,";1893 $col .= " cat.creator_id,";1894 $col .= " cat.create_date,";1895 $col .= " cat.update_date,";1896 $col .= " cat.del_flg, ";1897 $col .= " ttl.product_count";1898 $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id";1899 // 登録商品数のチェック1900 if($count_check) {1901 $where = "del_flg = 0 AND product_count > 0";1902 } else {1903 $where = "del_flg = 0";1904 }1905 $objQuery->setoption("ORDER BY rank DESC");1906 $arrRet = $objQuery->select($col, $from, $where);1907 1908 $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);1909 1910 foreach($arrRet as $key => $array) {1911 foreach($arrParentID as $val) {1912 if($array['category_id'] == $val) {1913 $arrRet[$key]['display'] = 1;1914 break;1915 }1916 }1917 }1918 1919 return $arrRet;1920 }1921 1922 // 親カテゴリーを連結した文字列を取得する1923 function sfGetCatCombName($category_id){1924 // 商品が属するカテゴリIDを縦に取得1925 $objQuery = new SC_Query();1926 $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);1927 $ConbName = "";1928 1929 // カテゴリー名称を取得する1930 foreach($arrCatID as $key => $val){1931 $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";1932 $arrVal = array($val);1933 $CatName = $objQuery->getOne($sql,$arrVal);1934 $ConbName .= $CatName . ' | ';1935 }1936 // 最後の | をカットする1937 $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2);1938 1939 return $ConbName;1940 }1941 1942 // 指定したカテゴリーIDの大カテゴリーを取得する1943 function sfGetFirstCat($category_id){1944 // 商品が属するカテゴリIDを縦に取得1945 $objQuery = new SC_Query();1946 $arrRet = array();1947 $arrCatID = SC_Utils_Ex::sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);1948 $arrRet['id'] = $arrCatID[0];1949 1950 // カテゴリー名称を取得する1951 $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";1952 $arrVal = array($arrRet['id']);1953 $arrRet['name'] = $objQuery->getOne($sql,$arrVal);1954 1955 return $arrRet;1956 1853 } 1957 1854
Note: See TracChangeset
for help on using the changeset viewer.