- Timestamp:
- 2014/07/10 23:50:09 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/helper/SC_Helper_BestProducts.php
r23546 r23568 171 171 public function rankUp($best_id) 172 172 { 173 $objDb = new SC_Helper_DB_Ex(); 174 //おすすめはデータベースの登録が昇順なので、Modeを逆にする。 175 $objDb->sfRankDown('dtb_best_products', 'best_id', $best_id); 173 $arrBestProducts = $this->getBestProducts($best_id); 174 $rank = $arrBestProducts['rank']; 175 176 if ($rank > 1) { 177 // 表示順が一つ上のIDを取得する 178 $arrAboveBestProducts = $this->getByRank($rank - 1); 179 $above_best_id = $arrAboveBestProducts['best_id']; 180 181 if ($above_best_id) { 182 // 一つ上のものを一つ下に下げる 183 $this->changeRank($above_best_id, $rank); 184 } else { 185 // 無ければ何もしない。(歯抜けの場合) 186 } 187 188 // 一つ上に上げる 189 $this->changeRank($best_id, $rank - 1); 190 } 176 191 } 177 192 … … 184 199 public function rankDown($best_id) 185 200 { 186 $objDb = new SC_Helper_DB_Ex(); 187 //おすすめはデータベースの登録が昇順なので、Modeを逆にする。 188 $objDb->sfRankUp('dtb_best_products', 'best_id', $best_id); 201 $arrBestProducts = $this->getBestProducts($best_id); 202 $rank = $arrBestProducts['rank']; 203 204 if ($rank < RECOMMEND_NUM) { 205 // 表示順が一つ下のIDを取得する 206 $arrBelowBestProducts = $this->getByRank($rank + 1); 207 $below_best_id = $arrBelowBestProducts['best_id']; 208 209 if ($below_best_id) { 210 // 一つ下のものを一つ上に上げる 211 $this->changeRank($below_best_id, $rank); 212 } else { 213 // 無ければ何もしない。(歯抜けの場合) 214 } 215 216 // 一つ下に下げる 217 $this->changeRank($best_id, $rank + 1); 218 } 219 } 220 221 /** 222 * 対象IDのrankを指定値に変更する 223 * 224 * @param integer $best_id 対象ID 225 * @param integer $rank 変更したいrank値 226 * @return void 227 */ 228 public function changeRank($best_id, $rank) 229 { 230 $objQuery =& SC_Query_Ex::getSingletonInstance(); 231 232 $table = 'dtb_best_products'; 233 $sqlval = array('rank' => $rank); 234 $where = 'best_id = ?'; 235 $arrWhereVal = array($best_id); 236 $objQuery->update($table, $sqlval, $where, $arrWhereVal); 189 237 } 190 238 }
Note: See TracChangeset
for help on using the changeset viewer.