<?php 

require_once "models/connection.php";
require_once "controllers/put.controller.php";

if(isset($_GET["id"])&&isset($_GET['nameId'])){

	$data = array();
	parse_str(file_get_contents('php://input'),$data);

	$columns = array();		

	foreach (array_keys($data) as $key => $value){

		array_push($columns,$value);

	}

	array_push($columns,$_GET['nameId']);
	$columns = array_unique($columns);

	$existe = Connection::getColumnsData($table,$columns);

	if(empty($existe)){

		$json = array(
			'status'=> 400,
			'result'=> 'Error: Fields in the form do not match the database'
		);

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

	$response = new PutController();
	$response-> putData($table,$data,$_GET["id"],$_GET['nameId']);


}





?>