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

 	public function addShop($shop_data = array()){
 		if(empty($shop_data)){
 			return 0;
 		}

 		$status = $this->db->insert('mechanic_shop',$shop_data);
		return ($status)?1:0;
 	}

 	function getShop($shop_id = '',$view_all = 0){
 		$cond = ($view_all != 0)?' status IN (0,1) ':' status IN (1) ';
 		$cond .= (!empty($shop_id))?" AND shop_id = '$shop_id'":"";

		$result = $this->db->query("SELECT * FROM mechanic_shop WHERE $cond");
		if(empty($result)){
			return;
		}
		return (empty($shop_id))?$result->result():$result->row();
 	}

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

 	function updateShop($shop_id = '', $shop_data = array()){
 		if(empty($shop_id) || empty($shop_data)){
 			return 0;
 		}
		
 		$status = $this->db->update('mechanic_shop',$shop_data,array('shop_id'=>$shop_id));
		return ($status)?1:0;
 	}

}
?>