commit a1b4ed874fa8695c408f5e9fb7e13c665f194465
parent fd840aa8946205779e247f8dacb42cd16e59c446
Author: Johs <[email protected]>
Date: Sun, 26 Mar 2023 15:39:16 +0200
Zou foutieve data naar schaduw tabel moeten sturen
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/datainserter.php b/datainserter.php
@@ -72,6 +72,25 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Execute prepared statement
$result = mysqli_stmt_execute($stmt);
+ // Second Insert for shadow table
+ if ($valid == 0) {
+ $sql2 = "SELECT data_id from weerdata where station_name = ? and datum_tijd = ?";
+ $stmt2 = mysqli_prepare($db_connection, $sql2);
+ mysqli_stmt_bind_param($stmt2, "is", $stn, $datetime);
+ $result = mysqli_stmt_execute($stmt2);
+ $row = mysqli_fetch_assoc($result);
+ $data_id = $row['data_id'];
+
+ $sql3 = "INSERT INTO weerdata_gecorrigeerd (station_name, origin_data_id, datum_tijd,gevalideerd,temp,dauwpunt,ldrk_znv,ldrk_station,zichtbaarheid,
+ windsnelheid,neerslag,sneeuwdpt,gebeurtenissen, vorst,regen,sneeuw,hagel,onweer,tornado, bewolking,windrichting)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ $stmt3 = mysqli_prepare($db_connection, $sql3);
+ $falsevalid = 1;
+ mysqli_stmt_bind_param($stmt3, "iisiddddddddsiiiiiidi", $stn, $result, $datetime, $falsevalid, $temp, $dewp, $stp, $slp, $visib, $wdsp, $prcp, $sndp, $frshtt, $vorst,$regen,$sneeuw,$hagel,$onweer,$tornado, $cldc, $wnddir);
+ $result = mysqli_stmt_execute($stmt3);
+
+ }
+
// Check if the insertion was successful
if ($result) {
echo "Data inserted successfully";