<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');
 
foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "ci_id")
    $ci_id = $paramValue;
  else if ($paramName == "instance")
    $instance = $paramValue;
  else if ($paramName == "location")
    $location = $paramValue;
  elseif ($paramName == "controlconfig_id") 
    $controlconfig_id = $paramValue;  
}

$dal = new DAL(); 
 
if ($ci_id == 0) 
  $sql = "INSERT INTO controlinit " .
         "(controlconfig_id, instance, location) " .
         "VALUES ($controlconfig_id, '$instance', '$location') ";
else
  $sql = "UPDATE controlinit " .
         "SET controlconfig_id=$controlconfig_id, location='$location', " .
         "instance=$instance " .
         "WHERE id = $ci_id ";

$result = $dal->query($sql);

echo json_encode($result);

?>

