Advertisement
kbohme

touchdownstatsdata.class

Aug 29th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2. //simpilotgroup addon module for phpVMS virtual airline system
  3. //
  4. //simpilotgroup addon modules are licenced under the following license:
  5. //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
  6. //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
  7. //
  8. //@author David Clark (simpilot)
  9. //@copyright Copyright (c) 2009-2010, David Clark
  10. //@license http://creativecommons.org/licenses/by-nc-sa/3.0/
  11.  
  12. class TouchdownStatsData extends CodonData {
  13.  
  14. public function get_all_stats() {
  15. $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
  16. WHERE landingrate < '0'
  17. ORDER BY landingrate DESC";
  18.  
  19. return DB::get_results($query);
  20. }
  21.  
  22. public function get_stats($howmany) {
  23. $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
  24. WHERE landingrate < '0'
  25. ORDER BY landingrate DESC
  26. LIMIT $howmany";
  27.  
  28. return DB::get_results($query);
  29. }
  30. public function pilot_stats($pilotid) {
  31. $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
  32. WHERE landingrate < '0'
  33. AND pilotid = '$pilotid'
  34. ORDER BY landingrate DESC";
  35.  
  36. return DB::get_results($query);
  37. }
  38.  
  39. public function pilot_average($pilotid) {
  40. $stats = self::pilot_stats($pilotid);
  41. $total = 0;
  42. $count = 0;
  43.  
  44. foreach ($stats as $stat)
  45. {
  46. $total = $total + $stat->landingrate;
  47. $count++;
  48. }
  49. $average = $total / $count;
  50.  
  51. return $average;
  52. }
  53.  
  54. public function airline_average() {
  55. $stats = self::get_all_stats();
  56. $total = 0;
  57. $count = 0;
  58.  
  59. foreach ($stats as $stat)
  60. {
  61. $total = $total + $stat->landingrate;
  62. $count++;
  63. }
  64. $average = $total / $count;
  65.  
  66. return $average;
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement