|
@@ 4986-5030 (lines=45) @@
|
| 4983 |
|
* @return Array the airport list |
| 4984 |
|
* |
| 4985 |
|
*/ |
| 4986 |
|
public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '') |
| 4987 |
|
{ |
| 4988 |
|
global $globalDBdriver; |
| 4989 |
|
$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 4990 |
|
FROM spotter_output |
| 4991 |
|
WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' "; |
| 4992 |
|
if ($olderthanmonths > 0) { |
| 4993 |
|
if ($globalDBdriver == 'mysql') { |
| 4994 |
|
$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
| 4995 |
|
} else { |
| 4996 |
|
$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
| 4997 |
|
} |
| 4998 |
|
} |
| 4999 |
|
if ($sincedate != '') { |
| 5000 |
|
if ($globalDBdriver == 'mysql') { |
| 5001 |
|
$query .= "AND date > '".$sincedate."' "; |
| 5002 |
|
} else { |
| 5003 |
|
$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)"; |
| 5004 |
|
} |
| 5005 |
|
} |
| 5006 |
|
|
| 5007 |
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 5008 |
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5009 |
|
$query .= "GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 5010 |
|
ORDER BY airport_departure_icao_count DESC"; |
| 5011 |
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
| 5012 |
|
|
| 5013 |
|
$sth = $this->db->prepare($query); |
| 5014 |
|
$sth->execute(); |
| 5015 |
|
|
| 5016 |
|
$airport_array = array(); |
| 5017 |
|
$temp_array = array(); |
| 5018 |
|
|
| 5019 |
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 5020 |
|
{ |
| 5021 |
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 5022 |
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
| 5023 |
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
| 5024 |
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
| 5025 |
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
| 5026 |
|
|
| 5027 |
|
$airport_array[] = $temp_array; |
| 5028 |
|
} |
| 5029 |
|
return $airport_array; |
| 5030 |
|
} |
| 5031 |
|
|
| 5032 |
|
/** |
| 5033 |
|
* Gets all detected departure airports of the airplanes that have flown over |
|
@@ 5038-5082 (lines=45) @@
|
| 5035 |
|
* @return Array the airport list |
| 5036 |
|
* |
| 5037 |
|
*/ |
| 5038 |
|
public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '') |
| 5039 |
|
{ |
| 5040 |
|
global $globalDBdriver; |
| 5041 |
|
$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
| 5042 |
|
FROM spotter_output, airport |
| 5043 |
|
WHERE spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao "; |
| 5044 |
|
if ($olderthanmonths > 0) { |
| 5045 |
|
if ($globalDBdriver == 'mysql') { |
| 5046 |
|
$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; |
| 5047 |
|
} else { |
| 5048 |
|
$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
| 5049 |
|
} |
| 5050 |
|
} |
| 5051 |
|
if ($sincedate != '') { |
| 5052 |
|
if ($globalDBdriver == 'mysql') { |
| 5053 |
|
$query .= "AND date > '".$sincedate."' "; |
| 5054 |
|
} else { |
| 5055 |
|
$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)"; |
| 5056 |
|
} |
| 5057 |
|
} |
| 5058 |
|
|
| 5059 |
|
//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 5060 |
|
//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
| 5061 |
|
$query .= "GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
| 5062 |
|
ORDER BY airport_departure_icao_count DESC"; |
| 5063 |
|
if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
| 5064 |
|
|
| 5065 |
|
$sth = $this->db->prepare($query); |
| 5066 |
|
$sth->execute(); |
| 5067 |
|
|
| 5068 |
|
$airport_array = array(); |
| 5069 |
|
$temp_array = array(); |
| 5070 |
|
|
| 5071 |
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 5072 |
|
{ |
| 5073 |
|
$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 5074 |
|
$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
| 5075 |
|
$temp_array['airport_departure_name'] = $row['departure_airport_name']; |
| 5076 |
|
$temp_array['airport_departure_city'] = $row['departure_airport_city']; |
| 5077 |
|
$temp_array['airport_departure_country'] = $row['departure_airport_country']; |
| 5078 |
|
|
| 5079 |
|
$airport_array[] = $temp_array; |
| 5080 |
|
} |
| 5081 |
|
return $airport_array; |
| 5082 |
|
} |
| 5083 |
|
|
| 5084 |
|
|
| 5085 |
|
|