我对 Yii 的 AuthManager 和用于 DB 表的架构感到困惑。
- AuthItem表中的类型字段只能介于 0 和 2 之间(Role=2, Task=1, Operation=0)?
- 您能否使用本教程中使用的博客举例说明我可以找到存储在bizrule和数据字段中的内容?
- userid字段必须是 varchar 吗?
此模式(对于 MySQL)会产生任何冲突吗?
CREATE TABLE `AuthItem` (
`name` varchar(60) NOT NULL,
`type` tinyint(1) unsigned NOT NULL,
`description` varchar(255),
`bizrule` text,
`data` text,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `AuthItemChild` (
`parent` varchar(60) NOT NULL,
`child` varchar(60) NOT NULL,
PRIMARY KEY (`parent`,`child`),
FOREIGN KEY (`parent`) REFERENCES `AuthItem` (`name`)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (`child`) REFERENCES `AuthItem` (`name`)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `AuthAssignment` (
`itemname` varchar(60) NOT NULL,
`userid` int(10) unsigned NOT NULL,
`bizrule` text,
`data` text,
PRIMARY KEY (`itemname`,`userid`),
FOREIGN KEY (`itemname`) REFERENCES `AuthItem` (`name`)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (`userid`) REFERENCES `User` (`userid`)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
提前致谢!