I’m confused about the Yii’s AuthManager in general and the schema used for DB tables.
- The type field in the AuthItem table can be only between 0 and 2 ( Role=2, Task=1, Operation=0 ) ?
- Could you make me an example of what I can find stored in the bizrule and data fields using the blog used in the tutorial ?
- The userid field must be a varchar ?
This schema ( for MySQL ) generates any conflict ?
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;
THANKS IN ADVANCE!
Yes type field have to be one of those values.
bizrule can be any string that holds an executable PHP code which
returnsfalseortrueand ends with a semicolon. And data should be a string contains some serialized value(s), you can use them by operating$datavariable in your bizrule.userid field can be of any type I think, but default
varcharimplementation comes from here.