|
@@ 260-293 (lines=34) @@
|
| 257 |
|
} |
| 258 |
|
return $all; |
| 259 |
|
} |
| 260 |
|
public function countAllDepartureAirports($limit = true) { |
| 261 |
|
if ($limit) $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
| 262 |
|
else $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
| 263 |
|
try { |
| 264 |
|
$sth = $this->db->prepare($query); |
| 265 |
|
$sth->execute(); |
| 266 |
|
} catch(PDOException $e) { |
| 267 |
|
echo "error : ".$e->getMessage(); |
| 268 |
|
} |
| 269 |
|
$all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 270 |
|
if (empty($all)) { |
| 271 |
|
$Spotter = new Spotter($this->db); |
| 272 |
|
$pall = $Spotter->countAllDepartureAirports($limit); |
| 273 |
|
$dall = $Spotter->countAllDetectedDepartureAirports($limit); |
| 274 |
|
$all = array(); |
| 275 |
|
foreach ($pall as $value) { |
| 276 |
|
$icao = $value['airport_departure_icao']; |
| 277 |
|
$all[$icao] = $value; |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
foreach ($dall as $value) { |
| 281 |
|
$icao = $value['airport_departure_icao']; |
| 282 |
|
if (isset($all[$icao])) { |
| 283 |
|
$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 284 |
|
} else $all[$icao] = $value; |
| 285 |
|
} |
| 286 |
|
$count = array(); |
| 287 |
|
foreach ($all as $key => $row) { |
| 288 |
|
$count[$key] = $row['airport_departure_icao_count']; |
| 289 |
|
} |
| 290 |
|
array_multisort($count,SORT_DESC,$all); |
| 291 |
|
} |
| 292 |
|
return $all; |
| 293 |
|
} |
| 294 |
|
public function countAllArrivalAirports($limit = true) { |
| 295 |
|
if ($limit) $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
| 296 |
|
else $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
@@ 294-327 (lines=34) @@
|
| 291 |
|
} |
| 292 |
|
return $all; |
| 293 |
|
} |
| 294 |
|
public function countAllArrivalAirports($limit = true) { |
| 295 |
|
if ($limit) $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
| 296 |
|
else $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
| 297 |
|
try { |
| 298 |
|
$sth = $this->db->prepare($query); |
| 299 |
|
$sth->execute(); |
| 300 |
|
} catch(PDOException $e) { |
| 301 |
|
echo "error : ".$e->getMessage(); |
| 302 |
|
} |
| 303 |
|
$all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 304 |
|
if (empty($all)) { |
| 305 |
|
$Spotter = new Spotter($this->db); |
| 306 |
|
$pall = $Spotter->countAllArrivalAirports($limit); |
| 307 |
|
$dall = $Spotter->countAllDetectedArrivalAirports($limit); |
| 308 |
|
$all = array(); |
| 309 |
|
foreach ($pall as $value) { |
| 310 |
|
$icao = $value['airport_arrival_icao']; |
| 311 |
|
$all[$icao] = $value; |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
foreach ($dall as $value) { |
| 315 |
|
$icao = $value['airport_arrival_icao']; |
| 316 |
|
if (isset($all[$icao])) { |
| 317 |
|
$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 318 |
|
} else $all[$icao] = $value; |
| 319 |
|
} |
| 320 |
|
$count = array(); |
| 321 |
|
foreach ($all as $key => $row) { |
| 322 |
|
$count[$key] = $row['airport_arrival_icao_count']; |
| 323 |
|
} |
| 324 |
|
array_multisort($count,SORT_DESC,$all); |
| 325 |
|
} |
| 326 |
|
return $all; |
| 327 |
|
} |
| 328 |
|
public function countAllMonthsLastYear($limit = true) { |
| 329 |
|
global $globalDBdriver; |
| 330 |
|
if ($globalDBdriver == 'mysql') { |