php 删除所有子集、所有子分类

摘自:https://www.php.cn/blog/detail/10924.html

public function test(){

$child =  $this->getAllNextId($id);

}



public function getAllNextId($id,$data=[]){

        $pids = $this->table('kn_product_category')->where('parentid',$id)->column('id');
        if(count($pids)>0){
            foreach($pids as $v){
                $data[] = $v;
                $data = $this->getAllNextId($v,$data); //注意写$data 返回给上级
            }
        }
        if(count($data)>0){
            return $data;
        }else{
            return false;
        }

    }


你可能感兴趣的:(php 删除所有子集、所有子分类)