Changeset 17155
- Timestamp:
- 2008/03/14 13:58:37 (15 years ago)
- Location:
- branches/comu-ver2/data/class
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/helper/SC_Helper_CSV.php
r16741 r17155 105 105 106 106 $from = "vw_product_class AS prdcls"; 107 $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols );107 $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id')); 108 108 109 109 $objQuery = new SC_Query(); … … 114 114 115 115 // 規格分類名一覧 116 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 116 if (!empty($arrOutputCols['classcategory_id1']) || !empty($arrOutputCols['classcategory_id2'])) { 117 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 118 } 117 119 118 120 if (!isset($data)) $data = ""; 119 121 for($i = 0; $i < $max; $i++) { 120 122 // 関連商品情報の付与 121 $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']]; 122 $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']]; 123 124 $arrCategory_id = $objQuery->getCol("dtb_product_categories", 125 "category_id", 126 "product_id = ?", 127 array($list_data[$i]['product_id'])); 128 129 // カテゴリID 付与 130 for ($j = 0; $j < count($arrCategory_id); $j++) { 131 $list_data[$i]['category_id'] .= $arrCategory_id[$j]; 132 if ($j < count($arrCategory_id) - 1) { 133 $list_data[$i]['category_id'] .= "|"; 123 if (in_array('classcategory_id1', $arrOutputCols)) { 124 $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']]; 125 } 126 if (in_array('classcategory_id2', $arrOutputCols)) { 127 $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']]; 128 } 129 130 if (in_array('category_id', $arrOutputCols)) { 131 $arrCategory_id = $objQuery->getCol("dtb_product_categories", 132 "category_id", 133 "product_id = ?", 134 array($list_data[$i]['product_id'])); 135 136 // カテゴリID 付与 137 for ($j = 0; $j < count($arrCategory_id); $j++) { 138 $list_data[$i]['category_id'] .= $arrCategory_id[$j]; 139 if ($j < count($arrCategory_id) - 1) { 140 $list_data[$i]['category_id'] .= "|"; 141 } 134 142 } 135 143 } 136 144 137 145 // 各項目をCSV出力用に変換する。 138 $data .= $this->lfMakeProductsCSV($list_data[$i] );146 $data .= $this->lfMakeProductsCSV($list_data[$i], $arrOutputCols); 139 147 } 140 148 return $data; … … 223 231 224 232 // 各項目をCSV出力用に変換する。(商品) 225 function lfMakeProductsCSV($list ) {233 function lfMakeProductsCSV($list, $arrOutputCols) { 226 234 $line = ""; 227 235 if(is_array($list)) { 228 foreach($ list as $key => $val) {236 foreach($arrOutputCols as $key) { 229 237 $tmp = ""; 230 238 switch($key) { … … 233 241 $tmp = '0'; 234 242 } else { 235 $tmp = $ val;243 $tmp = $list[$key]; 236 244 } 237 245 break; 238 246 default: 239 $tmp = $ val;247 $tmp = $list[$key]; 240 248 break; 241 249 } -
branches/comu-ver2/data/class/util/SC_Utils.php
r17137 r17155 489 489 490 490 // 配列の値をカンマ区切りで返す。 491 function sfGetCommaList($array, $space=true ) {491 function sfGetCommaList($array, $space=true, $arrPop = array()) { 492 492 if (count($array) > 0) { 493 493 $line = ""; 494 494 foreach($array as $val) { 495 if ($space) { 496 $line .= $val . ", "; 497 }else{ 498 $line .= $val . ","; 495 if (!in_array($val, $arrPop)) { 496 if ($space) { 497 $line .= $val . ", "; 498 } else { 499 $line .= $val . ","; 500 } 499 501 } 500 502 } 501 503 if ($space) { 502 504 $line = ereg_replace(", $", "", $line); 503 } else{505 } else { 504 506 $line = ereg_replace(",$", "", $line); 505 507 } 506 508 return $line; 507 } else{509 } else { 508 510 return false; 509 511 }
Note: See TracChangeset
for help on using the changeset viewer.