<?php
class Contactus_Model extends CI_Model{
        
        function insertForm($arr)
        {


                $data = array(
                    'inputname' => $arr['inputname'] ,
                    'inputemail' => $arr['inputemail'] ,
                    'staticmobile' => $arr['staticmobile'] ,
                    'inputgender' => $arr['inputgender'] ,
                    'inputage' => $arr['inputage'] ,
                    'inputmessage' =>  $arr['inputmessage'] ,
                );
                
                $this->db->insert('contactus_submit', $data);
                //return $this->db->insert_id();
                if($this->db->affected_rows() != 1){
                    return false;
                }
                else{
                    return true;
                }
                
        }
        
        function update($id, $arr)
        {


                $data = array(
                    'inputname' => $arr['inputname'] ,
                    'inputemail' => $arr['inputemail'] ,
                    'staticmobile' => $arr['staticmobile'] ,
                    'inputgender' => $arr['inputgender'] ,
                    'inputage' => $arr['inputage'] ,
                    'inputmessage' =>  $arr['inputmessage'] ,
                );


                $this->db->where('id', $id);
                $this->db->update('contactus_submit', $data);
                if($this->db->affected_rows() != 1){
                    return false;
                }
                else{
                    return true;
                }
        
        }
        
        function get()
        {       

                $this->db->select('id,inputname,inputemail,staticmobile,inputgender,inputage,inputmessage,updated  ');
                $this->db->from('contactus_submit');
                $this->db->where('deleted', 0);
                $this->db->order_by("id", "asc");
                $query=$this->db->get();

                return $query->result();
        }
        
        function get_id($id){
                $this->db->select('id,inputname,inputemail,staticmobile,inputgender,inputage,inputmessage,updated  ');
                $this->db->where('id', $id);
                $query = $this->db->get('contactus_submit');
                return $query->result();
        }
        
        function get_lang($lang)
        {
                
                $this->db->where('lang', $lang);
                $query = $this->db->get('contactus_submit');
                return $query->result();
                
        }
        
        function delete($id)
        {
                // $this->db->where('id', $id);
                // $this->db->delete('feature');
                $arr=array();
                $arr['deleted'] =1;
                $this->db->where('id', $id);
                $this->db->update('contactus_submit', $arr);
        }
        function countNumOfContactus(){
            $this->db->select('id');
            $this->db->from('contactus_submit');
            $this->db->where('deleted', 0);
            $query=$this->db->get();
            $num=$query->num_rows();

            return $num;
        }
        
}

?>