<?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", "insert into team_poule (idteam, tier, poule, idchampionship) values ($1, $2, $3, $4)");
	$addteamtopoule= pg_execute($dbconn, "addteamtopoule", array($idteam, $tier, $poule, $idchampionship));

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

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

	echo $resultjson;
?>
