<?php  

require_once "models/get.model.php";

class GetController{

	static public function getData($table,$select){

		$response = GetModel::getData($table,$select);

		$return = new GetController();
		$return-> fncResponse($response);

	}

	static public function getDataFilter($table,$select,$linkTo,$equalTo){

		$response = GetModel::getDataFilter($table,$select,$linkTo,$equalTo);

		$return = new GetController();
		$return-> fncResponse($response);

	}
	
    static public function getDataRange($table,$select,$linkTo,$equalTo,$filterTo,$inTo){

		$response = GetModel::getDataRange($table,$select,$linkTo,$equalTo,$filterTo,$inTo);

		$return = new GetController();
		$return-> fncResponse($response);

	}
	
    static public function getDataFilterStatus($table,$select,$linkTo,$equalTo){

		$response = GetModel::getDataFilterStatus($table,$select,$linkTo,$equalTo);

		$return = new GetController();
		$return-> fncResponse($response);

	}

	public function fncResponse($response){

		if(!empty($response)){

			$json = array(
				'status'=> 200,
				'total' => count($response),
				'result'=> $response
			);

		}else{

			$json = array(
				'status'=> 404,
				'result'=> "Not found",
			);

		}

		echo json_encode($json,http_response_code($json['status']));

	}

}

?>
