コード例 #1
0
 public function get_array_all()
 {
     if (empty($this->userid)) {
         $user = apiDB::getUserByEmail($_SERVER['PHP_AUTH_USER']);
         $locations = apiDB::getUserLocations($user->id, $this->columnName());
         if (count($locations) == 1) {
             return apiDB::getLocationMeasurements($locations[0]->locationid, $user->userid, get_class($this));
         } else {
             $error = array();
             $error["ERROR"] = "cannot display all measurements - please specify a location ID";
             return $error;
             //This is a hack
         }
     }
     return apiDB::getLocationMeasurements($this->locationid, $this->userid, get_class($this));
 }
コード例 #2
0
ファイル: apiDB.php プロジェクト: sasscaloadc/crowdweatherAPI
 static function getUserLocation($locationid, $userid, $level = 1)
 {
     $conxn = apiDB::getConnection();
     $location = new Location();
     $sql = "SELECT * FROM location WHERE id = " . $locationid . " AND userid = " . $userid;
     //$sql = "SELECT * FROM location l INNER JOIN userlocation ul on l.id = ul.locationid WHERE id = ".$locationid." AND userid = ".$userid;
     $result = pg_query($conxn, $sql);
     if (pg_num_rows($result) > 0) {
         $row = pg_fetch_array($result);
         if ($level > 0) {
             $location->latitude = $row["latitude"];
             $location->longitude = $row["longitude"];
             $location->name = $row["name"];
             $location->id = $row["id"];
             $location->userid = $row["userid"];
             $location->rain = apiDB::getLocationMeasurements($locationid, $userid, "Rain", $level - 1);
             $location->mintemp = apiDB::getLocationMeasurements($locationid, $userid, "Mintemp", $level - 1);
         } else {
             $location = $row["id"];
         }
     }
     pg_close($conxn);
     return $location;
 }