<?php
class Type_model extends CI_Model {

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


    
    public function get_type_name($_name){
        $query = $this->db->get_where('type', array('type_name' => $_name));
        return $query->row_array();
    }
    
    public function get_one_type($_id){
        $query = $this->db->get_where('type', array('type_id' => $_id));
        return $query->row_array();
    }
    
    public function update_type($_id,$_data){
        $this->db->where('type_id',$_id);
        $this->db->update("type",$_data);
        return $this->db->affected_rows();
    }
    public function add_type($_data){
        $this->db->insert("type",$_data);
        return $this->db->affected_rows();        
    }    
}

