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

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

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

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

 	public function createTag($tagData = array()){
 		if(empty($tagData)){
 			return 0;
 		}
 		$status = $this->db->insert('tags',$tagData);
 		return $status;
 	}

 	public function updateTags($tag_id = '', $tagData = array()){
 		if(empty($tag_id) || empty($tagData)){
 			return 0;
 		}
 		$status = $this->db->update('tags',$tagData,array('tag_id'=>$tag_id));
 		return $status;
 	}

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