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

 	public function getCategoryData($category_id='',$view=''){
 		$cond  = (!empty($view))?" status IN ($view) ":" status != '2' ";
 		$cond .= (!empty($category_id))?" AND cat_id='$category_id' ":"";

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

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

 	public function createCategory($categoryData = array()){
 		if(empty($categoryData)){
 			return 0;
 		}
 		$status = $this->db->insert('event_category',$categoryData);
 		return $status;
 	}

 	public function updateCategory($category_id = '', $categoryData = array()){
 		if(empty($category_id) || empty($categoryData)){
 			return 0;
 		}
 		$status = $this->db->update('event_category',$categoryData,array('cat_id'=>$category_id));
 		return $status;
 	}

 	public function changeStatus($category_id = '', $status = '0'){
 		if(empty($category_id)){
 			return 0;
 		}
 		$status = $this->db->update('event_category',array('status'=>$status),array('cat_id'=>$category_id));
 		return $status;
 	}
}
?>