35 lines
865 B
PHP
35 lines
865 B
PHP
<?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'];
|
|
|
|
$addracetopoule= pg_prepare($dbconn, "addracetopoule", "insert into race (tier, poule, idchampionship, idteam) values ($1, $2, $3, $4) returning idrace");
|
|
$addracetopoule= pg_execute($dbconn, "addracetopoule", array($tier, $poule, $idchampionship, $idteam));
|
|
|
|
if($addracetopoule===FALSE) {
|
|
$result['ok'] = false;
|
|
$result['error'] = 'insert race to poule failed: '.pg_last_error($dbconn);
|
|
} else {
|
|
$result['ok'] = true;
|
|
}
|
|
|
|
|
|
$result['post'] = $post;
|
|
|
|
//print message
|
|
$resultjson = json_encode($result);
|
|
|
|
echo $resultjson;
|
|
?>
|