Add and Remove operations for between stops
[bus.git] / betweenpoint.move.php
blob:a/betweenpoint.move.php -> blob:b/betweenpoint.move.php
--- a/betweenpoint.move.php
+++ b/betweenpoint.move.php
@@ -66,10 +66,12 @@
       $nodelat = (int)($lat * 10000000);
       $nodelon = (int)($lng * 10000000);
       echo($nodelat . "," . $nodelon . "=$geoPo<br>");
-      $sql = "UPDATE stops SET geohash='$geoPo', lat='$nodelat', lng='$nodelon' WHERE geohash = '{$_REQUEST['oldgeopo']}'";
+      $sql = "UPDATE stops SET geohash='$geoPo', lat='$nodelat', lng='$nodelon', name=null, suburb=null WHERE geohash = '{$_REQUEST['oldgeopo']}'";
       $result = pg_query($conn, $sql);
       if (!$result) {
           echo("Error in SQL query: " . pg_last_error() . "<br>\n");
+      } else if (pg_affected_rows($result) == 0) {
+	echo ("Error 0 points moved, please refresh page and try again");
       } else {
       echo $_REQUEST['oldgeopo'] . " replaced with $geoPo <br>";
       $updatedroutes = 0;