Changeset 21564 for branches/version-2_12-dev
- Timestamp:
- 2012/03/01 10:06:28 (12 years ago)
- Location:
- branches/version-2_12-dev/data/class
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_Product.php
r21527 r21564 173 173 } 174 174 175 $where = 'alldtl.product_id IN (' . implode(',', array_fill(0, count($arrProductId), '?')) . ')';175 $where = 'alldtl.product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrProductId)) . ')'; 176 176 $where .= ' AND alldtl.del_flg = 0'; 177 177 … … 410 410 } 411 411 $objQuery =& SC_Query_Ex::getSingletonInstance(); 412 $where = 'product_id IN (' . implode(', ', array_pad(array(), count($productIds), '?')) . ')';412 $where = 'product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)) . ')'; 413 413 if (!$has_deleted) { 414 414 $where .= ' AND T1.del_flg = 0'; … … 443 443 $cols = 'product_id, product_status_id'; 444 444 $from = 'dtb_product_status'; 445 $where = 'del_flg = 0 AND product_id IN (' . implode(', ', array_pad(array(), count($productIds), '?')) . ')';445 $where = 'del_flg = 0 AND product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)) . ')'; 446 446 $productStatus = $objQuery->select($cols, $from, $where, $productIds); 447 447 $results = array(); -
branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php
r21563 r21564 853 853 $objQuery =& SC_Query_Ex::getSingletonInstance(); 854 854 855 $where = "$pid_name IN (" . implode(',', array_fill(0, count($arrPID), '?')) . ")";855 $where = "$pid_name IN (" . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrPID)) . ')'; 856 856 857 857 $return = $objQuery->getCol($id_name, $table, $where, $arrPID); … … 921 921 $arrRet = SC_Helper_DB_Ex::sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $category_id); 922 922 923 $where = 'category_id IN (' . implode(',', array_fill(0, count($arrRet), '?')) . ')';923 $where = 'category_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrRet)) . ')'; 924 924 925 925 return array($where, $arrRet); -
branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php
r21551 r21564 496 496 497 497 // 削除されていない支払方法を取得 498 $where = 'del_flg = 0 AND payment_id IN (' . implode(', ', array_pad(array(), count($arrPaymentIds), '?')) . ')';498 $where = 'del_flg = 0 AND payment_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrPaymentIds)) . ')'; 499 499 $objQuery->setOrder('rank DESC'); 500 500 $payments = $objQuery->select('payment_id, payment_method, rule, upper_rule, note, payment_image, charge', 'dtb_payment', $where, $arrPaymentIds); -
branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php
r21563 r21564 282 282 $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 283 283 switch ($key) { 284 // 商品ID 285 case 'search_product_id': 286 $where .= ' AND product_id = ?'; 287 $arrValues[] = sprintf('%d', $objFormParam->getValue($key)); 288 break; 289 // 商品コード 290 case 'search_product_code': 291 $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)'; 292 $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key)); 293 break; 294 // 商品名 295 case 'search_name': 296 $where .= ' AND name LIKE ?'; 297 $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key)); 298 break; 299 // カテゴリ 300 case 'search_category_id': 301 list($tmp_where, $tmp_Values) = $objDb->sfGetCatWhere($objFormParam->getValue($key)); 302 if ($tmp_where != '') { 303 $where.= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; 304 $arrValues = array_merge((array)$arrValues, (array)$tmp_Values); 305 } 306 break; 307 // 種別 308 case 'search_status': 309 $tmp_where = ''; 310 foreach ($objFormParam->getValue($key) as $element) { 311 if ($element != '') { 312 if (SC_Utils_Ex::isBlank($tmp_where)) { 313 $tmp_where .= ' AND (status = ?'; 314 } else { 315 $tmp_where .= ' OR status = ?'; 284 // 商品ID 285 case 'search_product_id': 286 $where .= ' AND product_id = ?'; 287 $arrValues[] = sprintf('%d', $objFormParam->getValue($key)); 288 break; 289 // 商品コード 290 case 'search_product_code': 291 $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)'; 292 $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key)); 293 break; 294 // 商品名 295 case 'search_name': 296 $where .= ' AND name LIKE ?'; 297 $arrValues[] = sprintf('%%%s%%', $objFormParam->getValue($key)); 298 break; 299 // カテゴリ 300 case 'search_category_id': 301 list($tmp_where, $tmp_Values) = $objDb->sfGetCatWhere($objFormParam->getValue($key)); 302 if ($tmp_where != '') { 303 $where.= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; 304 $arrValues = array_merge((array)$arrValues, (array)$tmp_Values); 305 } 306 break; 307 // 種別 308 case 'search_status': 309 $tmp_where = ''; 310 foreach ($objFormParam->getValue($key) as $element) { 311 if ($element != '') { 312 if (SC_Utils_Ex::isBlank($tmp_where)) { 313 $tmp_where .= ' AND (status = ?'; 314 } else { 315 $tmp_where .= ' OR status = ?'; 316 } 317 $arrValues[] = $element; 316 318 } 317 $arrValues[] = $element; 318 } 319 } 320 321 if (!SC_Utils_Ex::isBlank($tmp_where)) { 322 $tmp_where .= ')'; 323 $where .= " $tmp_where "; 324 } 325 break; 326 // 登録・更新日(開始) 327 case 'search_startyear': 328 $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_startyear'), 329 $objFormParam->getValue('search_startmonth'), 330 $objFormParam->getValue('search_startday')); 331 $where.= ' AND update_date >= ?'; 332 $arrValues[] = $date; 333 break; 334 // 登録・更新日(終了) 335 case 'search_endyear': 336 $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_endyear'), 337 $objFormParam->getValue('search_endmonth'), 338 $objFormParam->getValue('search_endday'), true); 339 $where.= ' AND update_date <= ?'; 340 $arrValues[] = $date; 341 break; 342 // 商品ステータス 343 case 'search_product_statuses': 344 if (count($objFormParam->getValue($key)) > 0) { 345 $where .= ' AND product_id IN (SELECT product_id FROM dtb_product_status WHERE product_status_id IN ('; 346 foreach ($objFormParam->getValue($key) as $param) { 347 $where .= '?,'; 348 $arrValues[] = $param; 349 } 350 $where = preg_replace("/,$/", "))", $where); 351 } 352 break; 319 } 320 321 if (!SC_Utils_Ex::isBlank($tmp_where)) { 322 $tmp_where .= ')'; 323 $where .= " $tmp_where "; 324 } 325 break; 326 // 登録・更新日(開始) 327 case 'search_startyear': 328 $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_startyear'), 329 $objFormParam->getValue('search_startmonth'), 330 $objFormParam->getValue('search_startday')); 331 $where.= ' AND update_date >= ?'; 332 $arrValues[] = $date; 333 break; 334 // 登録・更新日(終了) 335 case 'search_endyear': 336 $date = SC_Utils_Ex::sfGetTimestamp($objFormParam->getValue('search_endyear'), 337 $objFormParam->getValue('search_endmonth'), 338 $objFormParam->getValue('search_endday'), true); 339 $where.= ' AND update_date <= ?'; 340 $arrValues[] = $date; 341 break; 342 // 商品ステータス 343 case 'search_product_statuses': 344 $arrPartVal = $objFormParam->getValue($key); 345 $count = count($arrPartVal); 346 if ($count >= 1) { 347 $where .= ' ' 348 . 'AND product_id IN (' 349 . ' SELECT product_id FROM dtb_product_status WHERE product_status_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', $count) . ')' 350 . ')'; 351 $arrValues = array_merge($arrValues, $arrPartVal); 352 } 353 break; 354 default: 355 break; 353 356 } 354 357 } -
branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSV.php
r21563 r21564 785 785 } 786 786 $count = count($arrItems); 787 $where = $tblkey .' IN (' . implode(',', array_fill(0, $count, '?')) . ')';787 $where = $tblkey .' IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', $count) . ')'; 788 788 789 789 $objQuery =& SC_Query_Ex::getSingletonInstance(); -
branches/version-2_12-dev/data/class/util/SC_Utils.php
r21563 r21564 2192 2192 /** 2193 2193 * 指定されたパスの配下を再帰的にコピーします. 2194 * @param string $imageDir コピー元ディレクトリのパス 2195 * @param string $destDir コピー先ディレクトリのパス 2194 * @param string $imageDir コピー元ディレクトリのパス 2195 * @param string $destDir コピー先ディレクトリのパス 2196 * @return void 2196 2197 */ 2197 2198 function copyDirectory($source_path, $dest_path) { … … 2199 2200 $handle=opendir($source_path); 2200 2201 while ($filename = readdir($handle)) { 2201 if ($filename === '.' || $filename === '..') continue;2202 if ($filename === '.' || $filename === '..') continue; 2202 2203 $cur_path = $source_path . $filename; 2203 2204 $dest_file_path = $dest_path . $filename; … … 2205 2206 // ディレクトリの場合 2206 2207 // コピー先に無いディレクトリの場合、ディレクトリ作成. 2207 if (!empty($filename) && !file_exists($dest_file_path)) mkdir($dest_file_path);2208 if (!empty($filename) && !file_exists($dest_file_path)) mkdir($dest_file_path); 2208 2209 SC_Utils_EX::copyDirectory($cur_path . '/', $dest_file_path . '/'); 2209 2210 } else { 2210 if (file_exists($dest_file_path)) unlink($dest_file_path);2211 if (file_exists($dest_file_path)) unlink($dest_file_path); 2211 2212 copy($cur_path, $dest_file_path); 2212 2213 } … … 2214 2215 } 2215 2216 2217 /** 2218 * 文字列を区切り文字を挟み反復する 2219 * @param string $input 繰り返す文字列。 2220 * @param string $multiplier input を繰り返す回数。 2221 * @param string $separator 区切り文字 2222 * @return string 2223 */ 2224 function repeatStrWithSeparator($input, $multiplier, $separator = ',') { 2225 return implode($separator, array_fill(0, $multiplier, $input)); 2226 } 2216 2227 }
Note: See TracChangeset
for help on using the changeset viewer.