phpcms_v9推送到其他栏目后再在其他栏目删除导致数据库出错

修改phpcms/model/content_model.class.php大概454行的update_category_items()函数

private function update_category_items($catid,$action = 'add',$cache = 0) {
    $this->category_db = pc_base::load_model('category_model');
    if($action=='add') {
        $this->category_db->update(array('items'=>'+=1'),array('catid'=>$catid));
    }  else {
                    $this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));
    }
    if($cache) $this->cache_items();
}


修改为:

private function update_category_items($catid,$action = 'add',$cache = 0) {
    $this->category_db = pc_base::load_model('category_model');
    if($action=='add') {
        $this->category_db->update(array('items'=>'+=1'),array('catid'=>$catid));
    }  else {
        $r =$this->category_db->get_one(array('catid'=>$catid));
                    if($r['items']>0)
                    {
                    $this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));
                    }
        //$this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));
    }
    if($cache) $this->cache_items();
}


你可能感兴趣的:(数据库,function,update,action)