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

 	public function addBrand($brand_data = array()){
 		if(empty($brand_data)){
 			return 0;
 		}
 		$status = $this->db->insert('product_brand',$brand_data);
		return ($status)?1:0;
 	}

 	function getBrand($brand_id = '',$view_all = 0){
 		$cond = ($view_all != 0)?' status IN (0,1) ':' status IN (1) ';
 		$cond .= (!empty($brand_id))?" AND brand_id = '$brand_id'":"";
		$result = $this->db->query("SELECT * FROM product_brand WHERE $cond");
		if(empty($result)){
			return;
		}
		return (empty($brand_id))?$result->result():$result->row();
 	}

 	function changeStatus($brand_id = '', $status = '0'){
 		if(empty($brand_id)){
 			return 0;
 		}
 		$status = $this->db->update('product_brand',array('status'=>$status), array('brand_id'=>$brand_id));
 		return $status;
 	}

 	function updateBrand($brand_id = '', $brand_data = array()){
 		if(empty($brand_id) || empty($brand_data)){
 			return 0;
 		}
 		$status = $this->db->update('product_brand',$brand_data,array('brand_id'=>$brand_id));
		return ($status)?1:0;
 	}

}
?>