Jump to content

Top 10 Touchdown


flyalaska

Recommended Posts

Tried that really screwed up my page. Here is the section of the code of TouchdownStatsData.class. The month section is at the bottom

aka.png

    public function get_all_stats() {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

    public function get_stats($howmany) {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   ORDER BY landingrate DESC
                   LIMIT $howmany";

       return DB::get_results($query);
   }


   public function get_pilot_landingstats($pilotid, $howmany)    {
$query = "SELECT *
	FROM `".TABLE_PREFIX."pireps`
	WHERE landingrate < '0'
	AND pilotid = '$pilotid' 
	ORDER BY landingrate DESC
	LIMIT $howmany;";

return DB::get_results($query);
   }

public function pilot_stats($pilotid)   {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   AND pilotid = '$pilotid'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

       public function get_all_stats($month) { 
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` 
                   WHERE landingrate < '0'
                   AND MONTH(submitdate) = '$month'
                   ORDER BY landingrate DESC"; 

       return DB::get_results($query); 

	}

Link to comment
Share on other sites

  • Administrators

There is a bracket or something missing in the file and you have the same name for two functions - get_all_stats - you need to rename one of them to something different but I can not see what you have missing without seeing the entire file. It could be a } or a ; missing somewhere above line 23.

Link to comment
Share on other sites

Line 23 is the closing bracket for the month section. Here is the whole code. I looked and everything seems to match with the others.

<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/

class TouchdownStatsData extends CodonData  {


public function get_all_stats($month) { 
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` 
                   WHERE landingrate < '0'
                   AND MONTH(submitdate) = '$month'
                   ORDER BY landingrate DESC"; 

       return DB::get_results($query); 

	}

   public function get_all_stats() {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

    public function get_stats($howmany) {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   ORDER BY landingrate DESC
                   LIMIT $howmany";

       return DB::get_results($query);
   }


   public function get_pilot_landingstats($pilotid, $howmany)    {
$query = "SELECT *
	FROM `".TABLE_PREFIX."pireps`
	WHERE landingrate < '0'
	AND pilotid = '$pilotid' 
	ORDER BY landingrate DESC
	LIMIT $howmany;";

return DB::get_results($query);
   }

public function pilot_stats($pilotid)   {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   AND pilotid = '$pilotid'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }



   public function pilot_average($pilotid) {
       $stats = self::pilot_stats($pilotid);
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }

   public function airline_average() {
       $stats = self::get_all_stats();
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }
}

Fatal error: Cannot redeclare TouchdownStatsData::get_all_stats() in /home/caspsh1/public_html/fly/core/common/TouchdownStatsData.class.php on line 25

Link to comment
Share on other sites

  • Administrators

Thats going to try to pull from the controller, I am not sure how you have done it but if you just have it in the data model you can get the info direct from there;

$data = TouchdownStatsData::top_landing_this_month('10');

Your function in the data model should look something like this if you after 10 records from the current month;

public function top_landing_this_month($howmany) {
       $today = getdate();
       $month = $today[mon];
       $year = $today[year];
       $query = "SELECT *
               FROM   phpvms_pireps
               WHERE landingrate <'0'
               AND MONTH(submitdate) = '$month'
               AND YEAR(submitdate) = '$year'
               ORDER BY landingrate DESC
               LIMIT $howmany;";

       return DB::get_results($query);
   }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...