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

PHP代码
  1. private function update_category_items($catid,$action = 'add',$cache = 0) {  
  2.     $this->category_db = pc_base::load_model('category_model');  
  3.     if($action=='add') {  
  4.         $this->category_db->update(array('items'=>'+=1'),array('catid'=>$catid));  
  5.     }  else {  
  6.                     $this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));  
  7.     }  
  8.     if($cache$this->cache_items();  
  9. }  

修改为:

PHP代码
  1. private function update_category_items($catid,$action = 'add',$cache = 0) {  
  2.     $this->category_db = pc_base::load_model('category_model');  
  3.     if($action=='add') {  
  4.         $this->category_db->update(array('items'=>'+=1'),array('catid'=>$catid));  
  5.     }  else {  
  6.         $r =$this->category_db->get_one(array('catid'=>$catid));  
  7.                     if($r['items']>0)  
  8.                     {  
  9.                     $this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));  
  10.                     }  
  11.         //$this->category_db->update(array('items'=>'-=1'),array('catid'=>$catid));  
  12.     }  
  13.     if($cache$this->cache_items();  
  14. }  

 

H5/JS/CSS | 评论(0) | 引用(0) | 阅读(4318)