<?php
class Nav_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }
    
    public function get_nav()
    {  
        $this->db->order_by ( 'nav_level', "asc" ); 
        $this->db->order_by ( 'nav_id', "asc" );
        $query = $this->db->get('nav');
         return $query->result ();
    }    

    public function get_one_nav($_id){
        $query = $this->db->get_where('nav', array('nav_id' => $_id));
        return $query->row_array();
    }
    
    public function update_nav($_id,$_data){
        $this->db->where('nav_id',$_id);
        $this->db->update("nav",$_data);
        return $this->db->affected_rows();
    }
    public function add_nav($_data){
        $this->db->insert("nav",$_data);
        return $this->db->affected_rows();
    }    
}

