Changeset 19546 for branches/camp
- Timestamp:
- 2010/11/07 04:46:13 (13 years ago)
- Location:
- branches/camp/camp-2_5-D/data/class
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/camp/camp-2_5-D/data/class/SC_Product.php
r19523 r19546 48 48 /** 検索用並び替え条件配列 */ 49 49 var $arrOrderData; 50 51 /**52 * SC_Queryインスタンスに設定された検索条件をもとに商品IDの配列を取得する.53 *54 * 検索条件は, SC_Query::getWhere() 関数で設定しておく必要があります.55 *56 * @param SC_Query $objQuery SC_Query インスタンス57 * @param array $arrVal 検索パラメータの配列58 * @return array 商品IDの配列59 */60 function findProductIds(&$objQuery, $arrVal = array()) {61 $table = <<< __EOS__62 dtb_products AS alldtl63 JOIN dtb_product_categories AS T264 ON alldtl.product_id = T2.product_id65 JOIN dtb_category66 ON T2.category_id = dtb_category.category_id67 __EOS__;68 // SC_Query::getCol() ではパフォーマンスが出ない69 $results = $objQuery->select('alldtl.product_id', $table, "", $arrVal,70 MDB2_FETCHMODE_ORDERED);71 foreach ($results as $val) {72 $resultValues[] = $val[0];73 }74 return array_unique($resultValues);75 }76 50 77 51 /** … … 154 128 return $objQuery->getOne( "SELECT count(*) FROM ( $sql_base ) as t" , $arrVal); 155 129 } 156 157 130 158 131 /** -
branches/camp/camp-2_5-D/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
r18875 r19546 62 62 $objSess = new SC_Session(); 63 63 $objDb = new SC_Helper_DB_Ex(); 64 $objQuery = new SC_Query();65 64 66 65 // 認証可否の判定 … … 82 81 $this->lfConvertParam(); 83 82 84 $where = " del_flg = 0";83 $where = "alldtl.del_flg = 0"; 85 84 $arrval = array(); 86 85 … … 99 98 list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); 100 99 if($tmp_where != "") { 101 $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";100 $where.= " AND alldtl.product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; 102 101 $arrval = array_merge((array)$arrval, (array)$tmp_arrval); 103 102 } 104 103 break; 105 104 case 'search_product_code': 106 $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";105 $where .= " AND alldtl.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)"; 107 106 $arrval[] = "$val%"; 108 107 break; … … 112 111 } 113 112 113 // 検索結果対象となる商品の数を取得 114 $objQuery =& SC_Query::getSingletonInstance(); 115 $objQuery->setWhere($where); 114 116 $objProduct = new SC_Product(); 115 $productIds = $objProduct->findProductIds($objQuery, $arrval); 116 117 // 行数の取得 118 $linemax = count($productIds); 119 $this->tpl_linemax = $linemax; 117 $linemax = $objProduct->findProductCount($objQuery, $arrval); 118 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 120 119 121 120 // ページ送りの処理 … … 132 131 $startno = $objNavi->start_row; 133 132 133 $objProduct = new SC_Product(); 134 $objQuery =& SC_Query::getSingletonInstance(); 135 $objQuery->setWhere($where); 136 134 137 // 取得範囲の指定(開始行番号、行数のセット) 135 138 $objQuery->setLimitOffset($page_max, $startno); … … 138 141 139 142 // 検索結果の取得 140 $this->arrProducts = $objProduct->lists($objQuery, $arrval); 141 $objProduct->setProductsClassByProductIds($productIds); 143 $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, $arrval); 144 145 $where = ""; 146 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 147 $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')'; 148 } else { 149 // 一致させない 150 $where = '0<>0'; 151 } 152 $objQuery =& SC_Query::getSingletonInstance(); 153 $objQuery->setWhere($where); 154 $arrProducts = $objProduct->lists($objQuery, $arrProduct_id); 155 156 //取得している並び順で並び替え 157 $arrProducts2 = array(); 158 foreach($arrProducts as $item) { 159 $arrProducts2[ $item['product_id'] ] = $item; 160 } 161 $this->arrProducts = array(); 162 foreach($arrProduct_id as $product_id) { 163 $this->arrProducts[] = $arrProducts2[$product_id]; 164 } 165 166 $objProduct->setProductsClassByProductIds($arrProduct_id); 142 167 $objJson = new Services_JSON(); 143 168 $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; ';
Note: See TracChangeset
for help on using the changeset viewer.