コード例 #1
0
ファイル: cate.php プロジェクト: lughong/shop
 public function del($cate_id)
 {
     if (!$cate_id) {
         return false;
     }
     $cate_id = $cate_id + 0;
     $cate_info = CateM::getCateInfoByCateId($cate_id);
     if ($cate_info) {
         $where = array();
         $where['cate_id'] = $cate_id;
         $rs = CateM::del($where);
         if ($rs) {
             //查看是否有子孙
             $cate_list = CateM::getAllCate();
             $son_tree = CateM::getSonTree($cate_list, $cate_id);
             if ($son_tree) {
                 //把子孙都删除了
                 foreach ($son_tree as $key => $val) {
                     $where = array();
                     $where['fid'] = $cate_id;
                     $where['cate_id'] = $val['cate_id'];
                     CateM::del($where);
                 }
             }
             echo '1';
         } else {
             echo '0';
         }
     } else {
         echo '0';
     }
     throw new Exception('exit');
 }