当前位置 : 首页 » 博文聚焦 » 正文

thinkphp rbac

分类 : 博文聚焦 | 发布时间 : 2012-06-08 09:28:47 | 浏览 : 253

http://www.lampbrother.net/php/bencandy.php?fid=70&id=935


1.    用户表(包含三个字段用户编号,用户名和用户密码)
    2.    用户组表(用户组编号和名字)
    3.    用户与组的对应关系表(组编号和用户编号)
    4.    节点表(节点编号,名字,注释,父路径编号,等级)(注:这个表很容易将人搞晕)
    5.    权限表(组编号,节点编号,父路径编号,等级)

-- 表的结构 `think_access`此表为五张表中的权限表
CREATE TABLE IF NOT EXISTS `think_access` (
  `role_id` smallint(6) unsigned NOT NULL,
  `node_id` smallint(6) unsigned NOT NULL,
  `level` tinyint(1) NOT NULL,
  `pid` int(11) DEFAULT NULL,
  KEY `groupId` (`role_id`),
  KEY `nodeId` (`node_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- 表的结构 `think_node`此表为五张表中的节点表
CREATE TABLE IF NOT EXISTS `think_node` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `title` varchar(50) DEFAULT NULL,
  `pid` smallint(6) unsigned NOT NULL,
  `level` tinyint(1) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `level` (`level`),
  KEY `pid` (`pid`),
  KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
-- 表的结构 `think_role`此表为五张表中的用户组表
CREATE TABLE IF NOT EXISTS `think_role` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
-- 表的结构 `think_role_user`此表为用户和组对应关系表
CREATE TABLE IF NOT EXISTS `think_role_user` (
  `role_id` mediumint(9) unsigned DEFAULT NULL,
  `user_id` char(32) DEFAULT NULL,
  KEY `group_id` (`role_id`),
  KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- 表的结构 `think_user`此表为用户表
CREATE TABLE IF NOT EXISTS `think_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(100) NOT NULL,
  `password` char(32) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;


相关阅读:

How to move an element into another element?

Convert HTML to PDF in .NET

100% width background image with an 'auto' height

Resize image proportionally with CSS?

Change the image source on rollover using jQuery

How to insert spaces/tabs in text using HTML/CSS?

Adjust width and height of iframe to fit with content in it

Refresh Part of Page (div)

IE8 support for CSS Media Query

How do I escape a single quote?