<?php 
class Country_model extends CI_Model {
	public function _consruct(){
		parent::_construct();
	}


public function getcountryData($country_id='',$view=''){
		$cond  = (!empty($view))?" status IN ($view) ":" status != '2' ";
		$cond .= (!empty($country_id))?" AND id='$country_id' ":"";

		$countryData = $this->db->query("SELECT * FROM country WHERE $cond");

		if(!empty($countryData)){
			return (empty($country_id))?$countryData->result():$countryData->row();
		}
		return 0;
	}

	 public function add_country($countryData){

		$qry = $this->db->insert('country',$countryData);

		if ($this->db->trans_status() === TRUE)
		{
			$this->db->trans_commit();
			return TRUE;
		}else
		{
			$this->db->trans_rollback();
			return false;
		}
	}

 function update_country($id,$categoryData)
    {


        $this->db->where('id',$id);
        $qry = $this->db->update('country',$categoryData);
        return true;


    }

function delete_country($id) {
		$data = array(  
			'status' => '2'   
		);  
		$this->db->where('id', $id);
		$result =  $this->db->update('country', $data); 

		if($result) {
			return "Success";
		}
		else {
			return "Error";
		}
	}


}
