freshJet Posted January 1, 2014 Report Share Posted January 1, 2014 This was originally a cry for help, but here's a nifty piece of code for you all to use. It shows the top five most frequent flights flown bu the airline. public function topRoutes(){ $query = "SELECT depicao, arricao, COUNT(*) AS count FROM phpvms_pireps GROUP BY depicao, arricao ORDER BY count DESC LIMIT 5"; $results = DB::get_results($query); return $results; } You can then return the depicao, arricao and count. 1 Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted January 3, 2014 Report Share Posted January 3, 2014 Thanks Iain, great I was looking for that for a longtime but where should that code but in? Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 4, 2014 Author Report Share Posted January 4, 2014 You can either place it in PilotStats.class.php or in your own class file. Call it by doing: echo PilotStats::topRoutes(); Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted January 6, 2014 Administrators Report Share Posted January 6, 2014 You can also use the built in function StatsData::TopRoutes($airline_code) which also will cache the data for a couple of hours (on release versions of phpVMS) to lighten the load on the system. Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 6, 2014 Author Report Share Posted January 6, 2014 Oh, I didn't realise there was a default function Quote Link to comment Share on other sites More sharing options...
freshJet Posted January 18, 2014 Author Report Share Posted January 18, 2014 You can also use the built in function StatsData::TopRoutes($airline_code) which also will cache the data for a couple of hours (on release versions of phpVMS) to lighten the load on the system. I looked at the default, mine is better as the default only shows the top routes based on the timesflown in the schedules. When you overwrite your schedules, these are reset to zero. With mine, it counts the routes manually from the PIREPs. Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted January 21, 2014 Administrators Report Share Posted January 21, 2014 Cool, you should send a pull request to the GitHub account, maybe Nabeel will update the code next time he does a merge. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.