<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');
 
foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id")
    $ip_id = $paramValue;
  else if ($paramName == "instrument_id")
    $instrument_id = $paramValue;
  elseif ($paramName == "perfperiod_id") 
    $perfperiod_id = $paramValue;  
  else if ($paramName == "changepct")
    $changepct = $paramValue;
}

$dal = new DAL(); 
 
if ($ip_id == 0) {
  $sql = "INSERT INTO instrperform " .
         "(instrument_id, perfperiod_id, changepct) " .
         "VALUES ($instrument_id, $perfperiod_id, '$changepct') ";
  $ip_id = $dal->query($sql);
}

else {
  $sql = "UPDATE instrperform " .
         "SET perfperiod_id=$perfperiod_id, changepct='$changepct' " .
         "WHERE id = $ip_id ";
  $result = $dal->query($sql);
}

echo json_encode($ip_id);

?>

