<?php
class Position_model extends CI_Model {

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

    public function get_area()
    {
        $query = $this->db->get('area');
        return $query->result ();
    }
    
    public function get_position_name($_name){
        $query = $this->db->get_where('position', array('position_name' => $_name));
        return $query->row_array();
    }
    
    public function get_one_position($_id){
        $query = $this->db->get_where('position', array('position_id' => $_id));
        return $query->row_array();
    }
    
    public function update_position($_id,$_data){
        $this->db->where('position_id',$_id);
        $this->db->update("position",$_data);
        return $this->db->affected_rows();
    }
    public function add_position($_data){
        $this->db->insert("position",$_data);
        return $this->db->affected_rows();        
    }    
}

