post['process_code']; pg_query($this -> dbconn, "BEGIN"); $res1 = pg_query($this -> dbconn, sprintf( "CREATE TABLE IF NOT EXISTS %s( id serial8, code text references hf_mes_scada_data_capture_node_configure(code), v_string text, v_int int, v_float float8, v_bool bool, device_code text, batch text, create_date timestamp )", $table_name )); $res2 = pg_insert( $this -> dbconn, 'hf_mes_scada_data_capture_node_configure', $this -> post ); if ($res1 and $res2) pg_query($this -> dbconn, "COMMIT"); else pg_query($this -> dbconn, "ROLLBACK"); pg_query($this -> dbconn, sprintf("SELECT create_hypertable('%s','create_date')", $table_name)); pg_query($this -> dbconn, sprintf( "CREATE INDEX ON %s (v_string, v_int, v_float, v_bool, create_date DESC) WHERE COALESCE(v_string, v_int::text, v_float::text, v_bool::text) IS NOT NULL ", $table_name )); } function remove_node() { } function update_node() { return pg_update( $this -> dbconn, 'hf_mes_scada_data_capture_node_configure', $this -> post, ['code' => $this -> post['code']] ); } function get_nodes() { $res = pg_query($this -> dbconn, "SELECT * FROM hf_mes_scada_data_capture_node_configure"); return pg_fetch_all($res); } }