add server update status field
This commit is contained in:
@@ -41,6 +41,14 @@ class ECommand {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
$return = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($return) {
|
||||
pg_update(
|
||||
$this -> dbconn,
|
||||
"hf_mes_scada_edgeserver_controller_server",
|
||||
['updated' => false],
|
||||
['id' => $this -> post -> server_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pg_insert(
|
||||
|
||||
@@ -108,13 +108,41 @@ class EConfigure {
|
||||
);
|
||||
}
|
||||
|
||||
function update_device () {
|
||||
return pg_update(
|
||||
function update_device() {
|
||||
pg_query($this -> dbconn, "BEGIN");
|
||||
|
||||
$res[] = pg_update(
|
||||
$this -> dbconn,
|
||||
'hf_mes_scada_edgeserver_controller_device',
|
||||
(array) $this -> post,
|
||||
['id' => $this -> post -> id]
|
||||
);
|
||||
|
||||
$res[] = $id_res = pg_query(
|
||||
$this -> dbconn, sprintf(
|
||||
"SELECT server_id
|
||||
FROM hf_mes_scada_edgeserver_controller_device
|
||||
WHERE id = '%s'
|
||||
LIMIT 1",
|
||||
$this -> post -> id
|
||||
)
|
||||
);
|
||||
$server_id = pg_fetch_row($id_res)[0];
|
||||
|
||||
$res[] = pg_update(
|
||||
$this -> dbconn,
|
||||
"hf_mes_scada_edgeserver_controller_server",
|
||||
['updated' => true],
|
||||
['id' => $server_id]
|
||||
);
|
||||
|
||||
if (in_array(false, $res)) {
|
||||
pg_query($this -> dbconn, "ROLLBACK");
|
||||
return false;
|
||||
} else {
|
||||
pg_query($this -> dbconn, "COMMIT");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function get_device() {
|
||||
|
||||
@@ -29,7 +29,8 @@ function init_db($server_name, $port, $user, $password) {
|
||||
port int2 NOT NULL,
|
||||
address text NOT NULL,
|
||||
create_date timestamp NOT NULL DEFAULT NOW(),
|
||||
note text
|
||||
note text,
|
||||
updated bool NOT NULL DEFAULT false
|
||||
)");
|
||||
pg_query($dbconn, "CREATE TABLE IF NOT EXISTS hf_mes_scada_edgeserver_controller_device (
|
||||
id serial2 primary key,
|
||||
|
||||
Reference in New Issue
Block a user