您的位置:时间博客>PHP>thinkphp5无限级分类递规获取子类ID

thinkphp5无限级分类递规获取子类ID

/**
*  递规获取某个分类下的所有子级
 * @param type $parentid 分类id
 */
public $son_id=array();

public function getIds($parentid){
    $list=Db::name("GoodsCategory")->where(["parent_id"=>$parentid])->select();
    foreach ($list as $key => $value) {
    	$this->son_id[]=$value['id'];
    	$this->getIds($value['id']);
    }
    return $this->son_id;
}


转载请注明本文标题和链接:《 thinkphp5无限级分类递规获取子类ID

相关推荐

网友评论 0

未登陆 表情
Ctrl+Enter快速提交