<?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
* UserRole Model
*/
class User_Role_Model extends CI_Model
{
	public $table = 'user_role';
	
	public function __construct()
	{
		parent::__construct();
	}

	public function insert(){

		$data = array(
			'role_name' => $this->input->post('user_role')
			);

		return $this->db->insert($this->table,$data);
	}

	public function update(){
		$data = array(
			'role_name' => $this->input->post('user_role')
		);
		$this->db->where('role_ID', $this->input->post('role_id'));
		return $this->db->update($this->table,$data);
	}

	public function get( $role_ID = null){
		if($role_ID==null){
			$query = $this->db->get($this->table);
			return $query->result();
		}
		$query = $this->db->get_where($this->table,array('role_ID' => $role_ID));
		return $query->row();
	}

	public function delete($role_ID){
		return $this->db->delete($this->table, array('role_ID' => $role_ID ));
	}
}