/** * 通过数据库的方式递归查询当前分类ID的所有子分类ID * @param $id * @return array * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function findAllChild($id): array { static $arr = []; $members = self::where('pid', $id)->select()->toArray(); foreach ($members as $member){ $parent = $this->model->find($member['id'])->toArray(); $arr[] = $parent; self::findAllChild($parent['id']); } return $arr; }
标签:arr,throws,parent,分类,ID,PHP,id From: https://www.cnblogs.com/felixwan/p/17001837.html