CREATE TABLE mainmenu (
menuid int(10) NOT NULL,
mainmenuname varchar(50) NOT NULL,
url varchar(100) NOT NULL,
PRIMARY KEY (menuid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
這是MainMenu的表如何在yii框架中用不同的用戶登錄創建datadriven菜單和子菜單?
CREATE TABLE submenu (
submenuid int(10) NOT NULL,
menuid int(10) NOT NULL,
submenuname varchar(50) NOT NULL,
url varchar(100) NOT NULL,
PRIMARY KEY (submenuid),
KEY menuid (menuid),
CONSTRAINT submenu_ibfk_1 FOREIGN KEY (menuid) REFERENCES mainmenu (menuid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
這是子表
CREATE TABLE user_rights (
user_id varchar(20) NOT NULL,
submenuid int(3) NOT NULL,
menuid int(3) NOT NULL,
accessrole varchar(20) DEFAULT NULL,
PRIMARY KEY (user_id,submenuid,menuid),
KEY submenuid (submenuid),
KEY menuid (menuid),
CONSTRAINT user_rights_ibfk_1 FOREIGN KEY (user_id) REFERENCES user (user_id),
CONSTRAINT user_rights_ibfk_2 FOREIGN KEY (submenuid) REFERENCES submenu (submenuid),
CONSTRAINT user_rights_ibfk_3 FOREIGN KEY (menuid) REFERENCES mainmenu (menuid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
這是用戶權限表
CREATE TABLE user (
username varchar(20) NOT NULL,
password varchar(20) NOT NULL,
user_id varchar(20) NOT NULL,
accessrole varchar(20) NOT NULL,
PRIMARY KEY (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
這是用戶表。
如何從與用戶權限tbl的accessrole關聯的數據庫加載菜單和子菜單?
感謝您的編輯。但如果你能幫我解決這個問題,那麼它很棒。 – prince
你嘗試過什麼嗎?如果是這樣,請添加該代碼。 – topher
http://www.yiiframework.com/wiki/295/database-driven-cmenu/ – prince