How to deal with PHP permission design

Source: Internet
Author: User
PHP permission design description: you want to create a PHP permission menu and cyclically export different main menus and sub-menus from the database based on different user logon. the database structure is as follows: pai_useraccount & nbsp; & nbsp; & nbsp ;\\ store user information pai_role & nbsp; PHP permission design
Description: I want to create a PHP permission menu. different main menus and submenus are cyclically generated from the database based on different user logins.
The database structure is as follows:
Performance_useraccount \ stores user information
Performance_role \ stores role information
Performance_resource \ stores menu information
Permission of role _permission \

Now, you can obtain the user ID obtained at login, the main menu owned by the user, but what should you do if you get the sub menu owned by the user? No clue
\ Select. roleID, B. resourceName, B. URL from pai_permission a join pai_resource B on. resourceID = B. resourceID where RoleID in (select RoleID from resource_useraccount where username = 'admin ');




// Database CIM
Create database cim default charset = utf8;

// User table
Create table pai_useraccount
(
ID int (4) not null primary key AUTO_INCREMENT,
UserName varchar (20 ),
PassWord varchar (20 ),
MobilePhone varchar (20 ),
CreateTM varchar (20 ),
UpdateTM varchar (20 ),
RoleID int (4)
) Default charset = UTF8;
// Data format and insert test data
Insert into user_useraccount (UserName, PassWord, MobilePhone, CreateTM, RoleID) values ('admin', '2016030', '2016030', '2016030', '10 ');
Insert into user_useraccount (UserName, PassWord, MobilePhone, CreateTM, RoleID) values ('Liu Cheng', '123456', '1234568', '1997-12-30 ', '20 ');
Insert into user_useraccount (UserName, PassWord, MobilePhone, CreateTM, RoleID) values ('{qiongfang', '2016030', '2016030', '2016030'-12-30 ', '30 ');


// Role table
Create table rule _role
(
RoleID int (4 ),
RoleName varchar (20 ),
Remark varchar (20)
) Default charset = UTF8;
// Insert test data
Insert into role _role (RoleID, RoleName, Remark) values ('10', 'super admin', 'all system authorization ');
Insert into role _role (RoleID, RoleName, Remark) values ('20', 'technical department ', 'with permissions such as customer service management ');
Insert into role _role (RoleID, RoleName, Remark) values ('30', 'Department manager', 'permission to modify data ');
Insert into role _role (RoleID, RoleName, Remark) values ('40', 'financial manager', 'attendance statistics and bonuses ');

 
// Resource table
Create table resource_resource
(
ResourceID int (4 ),
ResourceName varchar (20 ),
Remark varchar (20 ),
URL varchar (100 ),
);

Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'customer service management', 'managing routine customer service records', 'sevicemanager. php ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'customer service submenu 1', 'manage routine customer service records', 'sevicemanager. php? Action = add ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'customer service submenu 2', 'manage routine customer service records', 'sevicemanager. php? Action = del ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('20140901', 'Member management', 'Member addition and query', 'memberservice. php ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('20170101', 'query management', 'query management', 'search. php ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'Return Visit management', 'Return Visit to customer service record ', 'Visit. php ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'knowledge base ', 'product FAQ', 'knowledge. php ');
Insert into resource_resource (ResourceID, ResourceName, Remark, URL) values ('000000', 'data management', 'data Backup statistics relevance ', 'backup. php ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.