企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
>数据表设计 |序号|字段名|必选|备注| |:-|-|-|-| |1|id|*|primary key| |2|name|*|项目名| |3|level|*|级别| |4|type||级别类型| |5|status||当前级别状态| |6|pid|*|当前级别夫类| >示例参数数据 ![](https://img.kancloud.cn/2d/81/2d81f0c9f14a3de92d425b7c5c0743f2_1678x571.png) >示例源码 ```php <?php namespace app\\index\\model; use think\Model; class Rule extends Model{ public function getPlevel($pid){ $data = [ 'id' =>$pid ]; return $this->where($data)->column('level'); } public function getPid($id){ $data = [ 'id' =>$id ]; return $this->where($data)->column('pid'); } public function getdatas($id){ $data = [ 'id' => $id ]; return $this->where($data)->select(); } public function tree(){ $rule = [ 'status' => 1, 'type' =>1 ]; $data=$this->where($rule)->select(); return $this->sort($data); } public function sort($data,$pid=0){ static $arr=array(); foreach ($data as $k => $v) { if($v['pid']==$pid){ $arr[]=$v; $this->sort($data,$v['id']); } } return $arr; } } ```