首页 > 代码库 > thinkphp-无限分类下根据任意部门获取顶级部门ID
thinkphp-无限分类下根据任意部门获取顶级部门ID
根据所得到的部门编号获取顶级部门ID:
参数 - department_id
表格组织架构:
tab_departments
department_id parent_id name
1 1 顶级
2 1 第一级
.......
函数:
1 function getDepartmentId($department_id){ 2 $departments = M(‘tab_departments‘)->getField(‘department_id,parent_id‘); 3 4 while($departments[$department_id]>1){ 5 $department_id = $departments[$department_id]; 6 } 7 }
调用方法:
$department_id = session(‘department_id‘);//当前用户的岗位ID $top_id = getDepartmentId($depatment_id); dump($top_id);
thinkphp-无限分类下根据任意部门获取顶级部门ID
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。