Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
51 righe
1.7 KiB
51 righe
1.7 KiB
<?php |
|
error_reporting(E_ALL); |
|
ini_set("display_errors", 1); |
|
require_once 'dbconfig.php'; |
|
header("Access-Control-Allow-Origin: *"); |
|
if (isset($_GET['command'])) { |
|
if ($_GET['command']=="UPDATE") { |
|
$gid = $_GET['gid']; |
|
$notes = $_GET['notes']; |
|
try { |
|
$dbcon = new PDO("pgsql:host=".$dbconfig['_pgsql_db_host_'].";port=".$dbconfig['_pgsql_db_port_'].";dbname=".$dbconfig['_pgsql_db_name_'].";user=".$dbconfig['_pgsql_db_user_'].";password=".$dbconfig['_pgsql_db_pass_'].""); |
|
|
|
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
$stmt = $dbcon->prepare("UPDATE data_point SET notes = UPPER(:notes) WHERE gid = :gid"); |
|
$stmt->bindValue(":gid", $gid, PDO::PARAM_INT); |
|
$stmt->bindValue(":notes", $notes, PDO::PARAM_STR); |
|
if($stmt->execute()){ |
|
$response = array("response"=>"200","message"=>"updated"); |
|
header('Content-Type: application/json'); |
|
echo json_encode($response); |
|
$dbcon = null; |
|
exit; |
|
} else { |
|
$response = array("response"=>"500","message"=>$e->getMessage()); |
|
header('Content-Type: application/json'); |
|
echo json_encode($response); |
|
$dbcon = null; |
|
exit; |
|
} |
|
} catch (PDOException $e) { |
|
$response = array("response"=>"500","message"=>$e->getMessage()); |
|
header('Content-Type: application/json'); |
|
echo json_encode($response); |
|
$dbcon = null; |
|
exit; |
|
} |
|
} else { |
|
$response = array("response"=>"404","message"=>"Command is not properly set."); |
|
header('Content-Type: application/json'); |
|
echo json_encode($response); |
|
$dbcon = null; |
|
exit; |
|
} |
|
} else { |
|
$response = array("response"=>"404","message"=>"Command is not properly set."); |
|
header('Content-Type: application/json'); |
|
echo json_encode($response); |
|
$dbcon = null; |
|
exit; |
|
} |
|
?>
|