Jump to content

Aircraft statistics...


MrAmsterdam

Recommended Posts

Go to core/common/TouchdownStatsData.class.php

Add this to the file:

public function get_planemd11_stats($howmany) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND Aircraft = '2'

ORDER BY landingrate DESC

LIMIT $howmany";

return DB::get_results($query);

}

planemd11 can be edited to the plane that you would like to show.

AND Aircraft = '2' the 2 can be changed to the aircraft that you would like to show. (See the phpvms_aircraft table)

So in my case the MD11 has ID '2' in the 'phpvms_aircraft' table.

Next, you need to add the following rules to the core/modules/Touchdownstats/TouchdownStats.php

public function planemd11_landings($howmany) {

$this->set('stats', TouchdownStatsData::get_planemd11_stats($howmany));

$this->show('touchdownstats/touchdownstats_index.tpl');

}

Again, please make sure that the planemd11 in both rules are the changed to the same name as used in the core/common/TouchdownStatsData.class.php file.

When this is done, you can use this link to view the results:

yoursite/index.php/TouchdownStats/planemd11_landings/20 (and again, planemd11 needs to be the same as in the two files we have edited.

DEMO:

http://serious-airlines.com/index.php/pages/aircraftstatistics

It's my first little project...

Regards

Lucas

Link to comment
Share on other sites

  • 3 weeks later...

One question??? How do you combine the stats for ONE type of aircraft, when you have multiple registrations?? For instance, I have 5 different registration for the MD11. They do NOT show up under one total, for the purpose of the landing stats?! I tried to do:

public function get_planemd11_stats($howmany) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND Aircraft = '105,106,107,108,109'

ORDER BY landingrate DESC

LIMIT $howmany";

return DB::get_results($query);

}

Under the AND Aircraft = part, but it did not like that format. Is there a way to combine the same types??

Link to comment
Share on other sites

Guest lorathon

Personally I would add a left join and then use the aircraft icao as a filter if the aircraft icao's are the same.

This should work if your icao's on all of the MD-11's are the same.


public function get_icao_land_stats($icao, $howmany) 
{
$sql = 'SELECT p.*
		FROM '.TABLE_PREFIX.'pireps p
		LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft
		WHERE `landingrate` < \'0\'
		AND `icao` = \''.$icao.'\'
		ORDER BY landingrate DESC
		LIMIT '.$howmany
		;

$ret = DB::get_results($sql);

return $ret;
}

Link to comment
Share on other sites

Ok, that would be great, but how do I display the individual aircraft then? I would add what you just said into the "core/common/TouchdownStatsData.class.php" correct? Then what for the "core/modules/Touchdownstats/TouchdownStats.php" section? Sorry, I get lost too easy trying to follow :(

Link to comment
Share on other sites

What was said in the above mentioned part. I have multiple MD11's, lets say, with different registrations. The code Lucas mentioned at the top of this thread works, but only shows for ONE registration of MD11, for instance; it does not lump all the MD11's into one, as I would want, to show the proper stats for all. Does that not make sense?!

Link to comment
Share on other sites

Guest lorathon

If you want all pireps for the MD11 lumped into one array then the code I wrote is what you are looking for

It will return ($howmany) pireps that have the aircraft flown as ($icao)

Link to comment
Share on other sites

Guest lorathon

Example

We will assume that the code I wrote is in JeffData.class.php

$icao = 'MD11';
$howmany = '10';
$pireps = JeffData::get_icao_land_stats($icao, $howmany);

In the above example $pireps will be filled with 10 pireps. These pireps will be the 10 with the landing rate closest to zero but less than zero. All of the pireps in the array will have been flown with an aircraft that has an icao of "MD11". It would not matter what the registration number is.

So if Billy flew MD-11 NX-12345 and landed at -50.50

and Tommy flew MD-11 NX-54321 and landed at -24.34

Both of these would be in the array. Tommy's would be first in line since his landing rate is closer to zero.

You may want to add to the SELECT to retrieve more of the aircraft information for your table. a.registration, a.fullname, or a.* for all

Link to comment
Share on other sites

One question??? How do you combine the stats for ONE type of aircraft, when you have multiple registrations?? For instance, I have 5 different registration for the MD11. They do NOT show up under one total, for the purpose of the landing stats?! I tried to do:

public function get_planemd11_stats($howmany) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND Aircraft = '105,106,107,108,109'

ORDER BY landingrate DESC

LIMIT $howmany";

return DB::get_results($query);

}

Under the AND Aircraft = part, but it did not like that format. Is there a way to combine the same types??

Hi guys,

I saw that the above issue was already resolved... i just wanted to say that for my 737-800 i used this code:

-------------

public function get_plane738_stats($howmany) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND Aircraft = '1' OR Aircraft = '3' OR Aircraft = '8' OR Aircraft = '9' OR Aircraft = '12'

ORDER BY landingrate DESC

LIMIT $howmany";

return DB::get_results($query);

}

------------

To answer the above question.

Bye!

Lucas

Link to comment
Share on other sites

  • 4 weeks later...

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...