$row_select_values[] = $srow['name'];
}
}
- $query = sprintf ("SELECT compound FROM screw "
+ $query = sprintf ("SELECT compound,usage FROM screw "
."WHERE component = %d AND endtime is NULL "
."ORDER BY starttime DESC LIMIT 1", $row['id']);
$sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!");
title="<b>Compound</b>"
selected="$srow['compound']"
>
+<row_input name=usage
+ title="<b>Usage</b>"
+ value="<? echo $srow['usage']; ?>"
+ >
<?
$query = "SELECT id,name FROM organisation ORDER BY name";
$sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!");
CREATE TABLE screw (
component INT4 NOT NULL references component(id) on delete cascade,
compound INT4 NOT NULL references compound(id) on delete cascade,
+ usage TEXT NOT NULL DEFAULT '',
starttime timestamp with time zone DEFAULT '1980-01-01 00:00:00+01'::timestamp with time zone NOT NULL,
endtime timestamp with time zone DEFAULT NULL
);
$query = sprintf ("UPDATE screw SET endtime = now() WHERE oid = %d", $row['oid']);
$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);
+ $query = sprintf ("INSERT INTO screw (component,compound,usage,starttime) "
+ ."VALUES (%d,%d,'%s'now())", $id, $compound, addslashes ($usage));
$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,%s)", $id, $compound,
+ $query = sprintf ("INSERT INTO screw (component,compound,usage,starttime) "
+ ."VALUES (%d,%d,'%s'%s)", $id, $compound,
+ addslashes ($usage),
$starttime? "'".$starttime."'" : "now()");
$sth = pg_exec ($dbh, $query) or die_query("Cannot update component history!", $query);
}