<?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);

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

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

	if($pouledelete===FALSE) {
		$result['ok'] = false;
		$result['error'] = pg_last_error($dbconn);
	} else {
		//return data
		$result['ok'] = true;
		$result['debug'] = 'deleted poule '.$tier.' '.$poule.' '.$idchampionship;
	}

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

	echo $resultjson;
?>
