static function updateLocation($locationid, $location)
 {
     if (get_class($location) != "Location") {
         return "Error, received object other than Location for update";
     }
     $dbLocation = apiDB::getLocation($locationid);
     if (empty($dbLocation->id)) {
         return "Error, Invalid Location ID for Update";
     }
     $conxn = apiDB::getConnection();
     $updatestring = "set ";
     $updatestring .= "latitude = " . (empty($location->latitude) ? "latitude" : "'" . $location->latitude . "'");
     $updatestring .= ", ";
     $updatestring .= "longitude = " . (empty($location->longitude) ? "longitude" : "'" . $location->longitude . "'");
     $updatestring .= ", ";
     $updatestring .= "name = " . (empty($location->name) ? "name" : "'" . $location->name . "'");
     $sql = "UPDATE location " . $updatestring . " WHERE id = " . $locationid;
     $result = pg_query($conxn, $sql);
     if ($result) {
         $rows = pg_affected_rows($result);
         return $rows . " Location(s) updated";
     } else {
         return "Error with Location update query : " . pg_last_error($conxn);
     }
 }
 public function getInstanceDetails($id)
 {
     $location = empty($this->userid) ? apiDB::getLocation($id) : apiDB::getUserLocation($id, $this->userid);
     if (empty($location->id)) {
         return self::NO_SUCH_ID;
     }
     $user = apiDB::getUser($location->userid);
     if ($_SERVER['PHP_AUTH_USER'] != $user->email && $this->access <= 1) {
         return self::ACCESS_DENIED;
     }
     $this->latitude = $location->latitude;
     $this->longitude = $location->longitude;
     $this->name = $location->name;
     $this->userid = $location->userid;
     $this->id = $location->id;
     $this->rain = $location->rain;
     $this->mintemp = $location->mintemp;
     // 	Preserving $this->access however, to retain admin rights.
     return self::SETUP_OK;
 }