首页 > Web开发 > 详细

ThinkPHP 中权限管理控制(RBAC)

时间:2014-08-19 19:10:55      阅读:308      评论:0      收藏:0      [点我收藏+]

1.  查询当前用户可以访问哪些应用

select node.id,node.name from rice_role as role, rice_role_user as user,
rice_access as access, rice_node as node where user.user_id=3 and
user.role_id=role.id and (access.role_id=role.id or (access.role_id=role.pid and role.pid!=0))

 and role.status=1 and access.node_id=node.id  and node.level=1 and node.status=1 group by id

2. 查询当前用户可以访问哪些模块

SELECT node.id, node.name
FROM rice_role AS role, rice_role_user AS user, rice_access AS access, rice_node AS node
WHERE user.user_id =3
AND user.role_id = role.id
AND (
access.role_id = role.id
OR (
access.role_id = role.pid
AND role.pid !=0))
AND role.status =1
AND access.node_id = node.id
AND node.level =2
AND node.pid =1
AND node.status =1 group by id

 

3. 查询具体模块对应的方法

select node.id,node.name from
                    rice_role as role,
                    rice_role_user as user,
                    rice_access as access ,
                    rice_node as node
                    where user.user_id=3 and user.role_id=role.id and ( access.role_id=role.id  or (access.role_id=role.pid and role.pid!=0 ) ) and role.status=1 and access.node_id=node.id and node.level=3 and node.pid={$moduleId} and node.status=1  group by id

 

 

 

 

 

 

ThinkPHP 中权限管理控制(RBAC),布布扣,bubuko.com

ThinkPHP 中权限管理控制(RBAC)

原文:http://blog.csdn.net/rogerzhanglijie/article/details/38684287

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!