<?php
class Landingsubmenu_Model extends CI_Model{
        
        function insert($arr)
        {
                
                $this->db->insert('landing_submenu', $arr);
                return $this->db->insert_id();
                
        }
        
        function update($id, $arr)
        {
        
                $this->db->where('id', $id);
                $this->db->update('landing_submenu', $arr);
        
        }
        
        function get()
        {       

                    $this->db->select('landing_submenu.id,landing_submenu.main_id,landing_main.title as main_title,landing_submenu.title, landing_submenu.displayorder, landing_submenu.updated ');
                    
                    $this->db->order_by("main_id", "asc");
                    $this->db->order_by("displayorder","asc");
                    $this->db->from('landing_submenu');
                    $this->db->join('landing_main', 'landing_submenu.main_id = landing_main.id');
                    $query=$this->db->get();

                return $query->result();
        }

        function getbymainid($id)
        {       

                    $this->db->select('landing_submenu.id,landing_submenu.main_id,landing_main.title as main_title,landing_submenu.title, landing_submenu.displayorder, landing_submenu.updated ');
                     $this->db->where('main_id', $id);
                    $this->db->order_by("main_id", "asc");
                    $this->db->order_by("displayorder","asc");
                    $this->db->from('landing_submenu');
                    $this->db->join('landing_main', 'landing_submenu.main_id = landing_main.id');
                    $query=$this->db->get();

                return $query->result();
        }
        
        function get_id($id){
                $this->db->where('id', $id);
                $query = $this->db->get('landing_submenu');
                return $query->result();
        }
        
        function get_lang($lang)
        {
                
                $this->db->where('lang', $lang);
                $query = $this->db->get('landing_submenu');
                return $query->result();
                
        }
        
        function delete($id)
        {
                $this->db->where('id', $id);
                $this->db->delete('landing_submenu');
        }
         function update_rank($id, $rank)
        {
                $data = array(
                        'displayorder' => $rank
                );

                $this->db->where('id', $id);
                $this->db->update('landing_submenu', $data);

        }
        
}

?>