} else {
$endtime = "'".addslashes($endtime)."'";
}
+ if ($price == '') {
+ $price = "0.0";
+ }
if ($id) {
$query = sprintf ("UPDATE component SET name='%s',serno='%s',starttime='%s',endtime=%s,"
."owner=%d,hwtype=%d,price=%s,status='%s',comment='%s' "
$query = sprintf ("SELECT oid,compound FROM screw "
."WHERE component = %d AND endtime is NULL "
."ORDER BY starttime DESC LIMIT 1", $id);
- $sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!");
+ $sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!", $query);
if (pg_NumRows ($sth) > 0) {
$row = pg_fetch_array ($sth, 0);
if ($row['compound'] != $compound) {
$query = sprintf ("UPDATE screw SET endtime = now() WHERE oid = %d", $row['oid']);
- $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!");
+ $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!", $query);
$query = sprintf ("INSERT INTO screw (component,compound,starttime) "
."VALUES (%d,%d,now())", $id, $compound);
- $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!");
+ $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!", $query);
}
} else {
$query = sprintf ("INSERT INTO screw (component,compound,starttime) "
- ."VALUES (%d,%d,now())", $id, $compound);
- $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!");
+ ."VALUES (%d,%d,%s)", $id, $compound,
+ $starttime? "'".$starttime."'" ? "now()");
+ $sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!", $query);
}
}