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

public function add_Amenities($AmenitiesData){
		$qry = $this->db->insert('amenities',$AmenitiesData);

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

public function getAmenitiesData($Amenities_id='',$view=''){

		$cond  = (!empty($view))?" status IN ($view) ":" status != '2' ";
		$cond .= (!empty($Amenities_id))?" AND id='$Amenities_id' ":"";

		$AmenitiesData = $this->db->query("SELECT * FROM amenities WHERE $cond Order by id DESC");

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

public function update_Amenities($id,$AmenitiesData)
	{


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


	}

	function changeStatus($Amenities_id = '', $status = '0'){

 		if(empty($Amenities_id)){
 			return 0;
 		}
 		$status = $this->db->update('amenities',array('status'=>$status),array('id'=>$Amenities_id));
 		return $status;
 	}





}