<?php
/**
 * Author:echo
 * Email:sqlgun@qq.com
 * Date: 2018-7-17
 * 有偿二次开发，邮件联系
 */
class Role_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }
    
    public function get_role()
    {  
        $this->db->order_by ( 'role_id', "asc" );
        $query = $this->db->get('role');
         return $query->result ();
    }    

    public function get_nav(){
        $this->db->order_by ( 'nav_level', "asc" );
        $query = $this->db->get('nav');
        return $query->result ();
    }
    
    public function get_button()
    {
        $this->db->order_by ( 'button_level', "asc" );
        $query = $this->db->get('button');
        return $query->result ();
    }    
    
    public function get_one_role($_id){
        $query = $this->db->get_where('role', array('role_id' => $_id));
        return $query->row_array();
    }
    public function update_role($_id,$_data){
        $this->db->where('role_id',$_id);
        $this->db->update("role",$_data);
        return $this->db->affected_rows();
    }
    public function add_role($_data){
        $this->db->insert("role",$_data);
        return $this->db->affected_rows();        
    }    
}

