<?php
	include_once("db.php");

	//make result object
	$result = array();
	$result['ok'] = false;

	//get post data
	$postdata = file_get_contents("php://input");
	$post = json_decode($postdata, true);

	$idchampionship = $post['idchampionship'];
	$idteam = $post['idteam'];
	$tier = $post['tier'];
	$poule = $post['poule'];

	$addteamtopoule= pg_prepare($dbconn, "addteamtopoule", "delete from team_poule where idteam = $1 and tier = $2 and poule = $3 and idchampionship = $4");
	$addteamtopoule= pg_execute($dbconn, "addteamtopoule", array($idteam, $tier, $poule, $idchampionship));

	if($addteamtopoule===FALSE) {
		$result['ok'] = false;
		$result['error'] = 'delete from team_poule failed: '.pg_last_error($dbconn);
	} else {
		$result['ok'] = true;
	}

	//print message
	$resultjson =  json_encode($result);

	echo $resultjson;
?>
