亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

?? ???? ?? ??

?? ???? ?? ??

???? ???? ?? ????. ?? ?? ??? ? ?? ????? ???? ???. ?? ?. cate ???? controll

 public function del($id){
        $cata=D('cate');
        $childids=$cata->getchild($id);
        $childids=implode(',',$childids);
        if($cata->delete($childids)){
          $this->success('刪除欄目成功!',U('index'));
        }else{
            $this->error('刪除欄目失?。?#39;);
        }
    }

catemodel ?? layer

 public function getchild($cateid){
        $data=$this->select();
        return $this->getchildids($data,$cateid);
    }
    public function getchildids($data,$cateid){
        static $res=array();
        $res[]=$cateid;
        foreach ($data as $k => $v) {
            if ($v['pid']==$cateid) {
                    $res[]=$v['id'];
                    $this->getchildids($data,$v['id']);

            }
        }
        return array_unique($res);
    }
let 's with rayers

$ childids = $ cata- & gt; getchild ($ id); getchild ????.

public function getchild($cateid){
        $data=$this->select();
        return $this->getchildids($data,$cateid);
    }
??? getchild ???? ??? ID? ?? ? ?? ????? ?????. getchildids ???? ???? ID? ?????.
  public function getchildids($data,$cateid){
        static $res=array();
        $res[]=$cateid;
        foreach ($data as $k => $v) {
            if ($v['pid']==$cateid) {
                    $res[]=$v['id'];
                    $this->getchildids($data,$v['id']);

            }
        }
        return array_unique($res);
    }
$res=array();??? ?????. $res[]=$cateid; ? ??? ID? ???? ? ?????.

foreach? ???? ?????. pid? ?? ID? ??? ?? ID? ????? ?????. ? ?? $res[] ? ???? ????? ?? ?????.

return array_unique($res); Eileen? ? ??? ???? array_unique? ?? ??? ?????.

$childids=implode(',',$childids); ??? ???? ???? ??? ? ????.

??? ?? ???? ?? ?? ??? ?? ??? ? ????.

???? ??
||
<?php namespace Admin\Controller; use Think\Controller; class CateController extends CommonController { public function index(){ $cate=D('cate'); $cateres=$cate->catetree(); $this->assign('cateres',$cateres);//獲取欄目樹 $this->display(); } public function add(){ $cate=D('cate'); if (IS_POST) { if($cate->create()){ if ($cate->add()) { $this->success('添加商品分類成功',U('Cate/add')); }else{ $this->error('添加商品分類失敗!'); } }else{ $this->error($cate->getError()); } return; } $cateres=$cate->catetree(); $this->assign('cateres',$cateres); $this->display(); } public function edit(){ $cate=D('cate'); if (IS_POST) { if($cate->create()){ if ($cate->save()!== false) { $this->success('修改商品分類成功',U('Cate/index')); }else{ $this->error('修改商品分類失敗!'); } }else{ $this->error($cate->getError()); } return; } $cates=$cate->find(I('id')); $cateres=$cate->catetree(); $this->assign('cateres',$cateres); $this->assign('cates',$cates); $this->display(); } public function del($id){ $cata=D('cate'); $childids=$cata->getchild($id); $childids=implode(',',$childids); if($cata->delete($childids)){ $this->success('刪除欄目成功!',U('index')); }else{ $this->error('刪除欄目失敗!'); } } }