今天编辑向我反馈,在使用discuz的插件——礼品商城时,实物礼品不能做到全部启用,即启用了第一页的,再去启用第二页的时候,第一页的又全部置为不启用状态了
查看原因是在修改该属性时,先把全部记录的该属性置为不启用状态,然后获取勾选的选项记录,将其属性置为启用状态,因此出现了上述情况。
- DB::query("UPDATE ".DB::table('market_goods')." SET available = '0'");
- if($_G['gp_available'] && is_array($_G['gp_available']) && count($_G['gp_available']) > 0){
- $delete = implode(',',$_G['gp_available']);
- DB::query("UPDATE ".DB::table('market_goods')." SET available = '1' WHERE id IN ($delete)");
- }
根据这种情况,我选择按页修改,即每次都只置当前页的为不启用状态,然后根据获取的勾选项的记录,将其置为启用状态。(具体文件是goods.inc.php,card.inc.php)
- //按页启用实物类,edit by zengyx 2012-3-29
- $ppp = 20;
- $pagenum = max(1, intval($_G['gp_page']));
- $start = ($pagenum - 1)*$ppp;
- $addsql = "iscard <> 1";
- $query = DB::query("SELECT id FROM ".DB::table('market_goods')." WHERE $addsql ORDER BY available DESC,displayorder ASC LIMIT $start,$ppp");
- $ids[] ='0';
- while($result = DB::fetch($query)){
- $ids[] = $result[id];
- }
- $ids = implode(',',$ids);
- DB::query("UPDATE ".DB::table('market_goods')." SET available = '0' where $addsql and id IN (0,$ids)");
- //end
- if($_G['gp_available'] && is_array($_G['gp_available']) && count($_G['gp_available']) > 0){
- $delete = implode(',',$_G['gp_available']);
- DB::query("UPDATE ".DB::table('market_goods')." SET available = '1' WHERE id IN ($delete)");
- }
阅读(1099) | 评论(2) | 转发(0) |