iwa-panda1

Manage Weather Data by International Weather Agency (Version 1)
Log | Files | Refs

commit 57e8323bae3a1bfb4bbd78ed0fccaccdf92d2080
parent beb5e0b50d95130125250bdec568a942629fb89c
Author: Kninteman <[email protected]>
Date:   Tue,  4 Apr 2023 12:54:07 +0200

Update datainserter.php

Diffstat:
Mdatainserter.php | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/datainserter.php b/datainserter.php @@ -67,8 +67,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $valid = validate_temperature($stn, $temp, $redis); // Prepare SQL INSERT-statement - $sql = "INSERT INTO weerdata (station_name,datum_tijd,gevalideerd,temp,dauwpunt,ldrk_znv,ldrk_station,zichtbaarheid, - windsnelheid,neerslag,sneeuwdpt,gebeurtenissen, vorst,regen,sneeuw,hagel,onweer,tornado, bewolking,windrichting) + $sql = "INSERT INTO weather_data (station_name,date_time,validated,temperature,dew_point,pressure_sea,pressure_station,visibility, + wind_speed,precipitation,snow_depth,events,frost_boolean,rain_boolean,snow_boolean,hail_boolean,thunder_boolean,tornado_boolean,cloud_count,wind_direction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; // Create prepared statement with the SQL statement @@ -78,15 +78,15 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $datetime = $date . " " . $time; // Extract the boolean values from $frshtt - $vorst = (int)substr($frshtt, 0, 1); - $regen = (int)substr($frshtt, 1, 1); - $sneeuw = (int)substr($frshtt, 2, 1); - $hagel = (int)substr($frshtt, 3, 1); - $onweer = (int)substr($frshtt, 4, 1); + $frost = (int)substr($frshtt, 0, 1); + $rain = (int)substr($frshtt, 1, 1); + $snow = (int)substr($frshtt, 2, 1); + $hail = (int)substr($frshtt, 3, 1); + $thunder = (int)substr($frshtt, 4, 1); $tornado = (int)substr($frshtt, 5, 1); // Bind parameters to prepared statement - mysqli_stmt_bind_param($stmt, "isiddddddddsiiiiiidi", $stn, $datetime, $valid, $temp, $dewp, $stp, $slp, $visib, $wdsp, $prcp, $sndp, $frshtt, $vorst, $regen, $sneeuw, $hagel, $onweer, $tornado, $cldc, $wnddir); + mysqli_stmt_bind_param($stmt, "isiddddddddsiiiiiidi", $stn, $datetime, $valid, $temp, $dewp, $stp, $slp, $visib, $wdsp, $prcp, $sndp, $frshtt, $frost, $rain, $snow, $hail, $thunder, $tornado, $cldc, $wnddir); // Execute prepared statement, only if the data is not within the first 30 entries $result = mysqli_stmt_execute($stmt); @@ -100,7 +100,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Second Insert for shadow table if ($valid == -1) { - $sql2 = "SELECT data_id from weerdata where station_name = ? and datum_tijd = ?"; + $sql2 = "SELECT data_id from weather_data where station_name = ? and date_time = ?"; $stmt2 = mysqli_prepare($db_connection, $sql2); mysqli_stmt_bind_param($stmt2, "is", $stn, $datetime); $stmt2->execute(); @@ -108,12 +108,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $row = $result->fetch_assoc(); $data_id = $row['data_id']; - $sql3 = "INSERT INTO weerdata_gecorrigeerd (station_name, origin_data_id, datum_tijd,temp,dauwpunt,ldrk_znv,ldrk_station,zichtbaarheid, - windsnelheid,neerslag,sneeuwdpt,gebeurtenissen, vorst,regen,sneeuw,hagel,onweer,tornado, bewolking,windrichting) + $sql3 = "INSERT INTO weather_data_corrected (station_name, origin_data_id, date_time,temperature,dew_point,pressure_sea,pressure_station,visibility, + wind_speed,precipitation,snow_depth,events,frost_boolean,rain_boolean,snow_boolean,hail_boolean,thunder_boolean,tornado_boolean,cloud_count,wind_direction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmt3 = mysqli_prepare($db_connection, $sql3); $new_temp = round($redis->lIndex('average'.$stn, 0), 1); - mysqli_stmt_bind_param($stmt3, "iisddddddddsiiiiiidi", $stn, $data_id, $datetime, $new_temp, $dewp, $stp, $slp, $visib, $wdsp, $prcp, $sndp, $frshtt, $vorst, $regen, $sneeuw, $hagel, $onweer, $tornado, $cldc, $wnddir); + mysqli_stmt_bind_param($stmt3, "iisddddddddsiiiiiidi", $stn, $data_id, $datetime, $new_temp, $dewp, $stp, $slp, $visib, $wdsp, $prcp, $sndp, $frshtt, $frost, $rain, $snow, $hail, $thunder, $tornado, $cldc, $wnddir); $result = mysqli_stmt_execute($stmt3); }