PHP »
编程开发 » ThinkPHP权限管理,access权限删除,权限批量删除
ThinkPHP权限管理,access权限删除,权限批量删除
今天有一同事在做ThinkPHP项目权限管理的时候,想多了,于是我就写了一个删除权限的方法:
[php]
function test(){
$this->delAll(2, 1, 1);
}
public function delAll($role_id,$node_id,$level){
$a = M('Access');
$map['pid'] = array('eq', $node_id);
$find = $a->where($map)->field('role_id,node_id,level')->select();
if ($find){
foreach ($find as $k=>$v){
$this->delAll($find[$k]['role_id'], $find[$k]['node_id'], $find[$k]['level']);
}
}
$condition['role_id'] = array('eq', $role_id);
$condition['node_id'] = array('eq', $node_id);
$condition['level'] = array('eq', $level);
$a->where($condition)->delete();
dump($a->getLastSql());
}
[/php]