36 lines
839 B
PHP
36 lines
839 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);
|
|
|
|
$idrace = $post['idrace'];
|
|
|
|
//fetch the drive
|
|
$drivefetch = pg_prepare($dbconn, "drivefetch", "select drive.*, driver.name drivername,
|
|
(select count(*) from comment where idrace = drive.idrace and drivenr = drive.drivenr) commentcount
|
|
from drive inner join driver using (iddriver) where idrace = $1");
|
|
$drivefetch = pg_execute($dbconn, "drivefetch", array($idrace));
|
|
|
|
//build result object
|
|
$drives = array();
|
|
while($row = pg_fetch_assoc($drivefetch)) {
|
|
$drives[] = $row;
|
|
}
|
|
|
|
$result['drives'] = $drives;
|
|
|
|
//return data
|
|
$result['ok'] = true;
|
|
|
|
//print message
|
|
$resultjson = json_encode($result);
|
|
|
|
echo $resultjson;
|
|
?>
|