db->where('status', 1); $this->db->where('level >=', $role); $query = $this->db->get($this->table); return $query->result_array(); } public function get_default_privilege($role){ $this->db->select('id'); $this->db->where('status', 1); $this->db->where('level >=', $role); if ($role == COMPANY_CUSTOMER) { $this->db->where('parentid', 1); } $query = $this->db->get($this->table); $result = $query->result_array(); $privilegeid = array(); foreach ($result as $key => $value) { $privilegeid[] = $value['id']; } return join(',', $privilegeid); } // 获取权限action public function get_privilege_action($ids){ $sql = "select action from {$this->table} where id in ({$ids})"; $res = $this->db->query($sql)->result_array(); $data = array(); foreach ($res as $v) { if (!empty($v['action'])) { $data[] = $v['action']; } } return empty($data) ? $data : explode(',', implode(',', $data)); } }