Sharing of permission handling for frame-based web systems, especially for large projects and two development projects
Users table is the user table, you can store tens of thousands of users also do not matter, the following groupid is 1 is the administrator rights, 2 is the visitor rights
The model table stores the name of each method of the framework, and the following group is the set collection type, which represents which group has this permission
Nonsense not much to say, look at the example code
PHP Code
Find ("User", "string", "user="). $user. "'"); $group _tmp= $data ["GroupID"]; $this->show ($group _tmp); Public function Show ($group _tmp) {$list = $this->find ("Model", "string", "func= ' Show '"); $sql = "SELECT * from model where func= ' show ' and Find_in_set (". $group _tmp. ",". $list [' group ']. "); if (Mysql_num_rows (mysql_query ($sql))) {echo "permission passed"; Handle the following content}else{echo "no permission"; }} Public Function ShowAll ($group _tmp) {$list = $this->find ("Model", "string", "func= ' ShowAll ' "); $sql = "SELECT * from model where func= ' ShowAll ' and Find_in_set (". $group _tmp. ",". $list [' group ']. "); if (Mysql_num_rows (mysql_query ($sql))) {echo "permission passed"; Handle the following content}else{echo "no permission"; }}}?>
Welcome reference ...
------Solution--------------------
The model table needs to be given the model name, otherwise the different model's same name method cannot be distinguished