airmermaid Posted April 2, 2011 Report Posted April 2, 2011 Hello In my statistics on main page I have tried to add a "totat passengers carried" field. To my surprise the number shown was unbelieveable. According to it my airline has carried around 104000 passengers with only 27 flights. Which makes around 3800 persons per flight. I took the data from .../core/common/StatsData.class.php (field is TotalPaxCarried). Am I looking at wrong place for that data? I also would like to know if there's a way to add Total Cargo Carried because my airline has a cargo section too. Cheers, Arslan Quote
Nuclear Posted April 2, 2011 Report Posted April 2, 2011 I just tested it and it returned a reasonable value for me (2945 pax for 38 flights). Can you post the actual code you're using? As for the total cargo, I don't see any built-in methods for that. You'd have to write an SQL query to sum the 'load' field for all filed PIREPs. 1 Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 I just tested it and it returned a reasonable value for me (2945 pax for 38 flights). Can you post the actual code you're using? As for the total cargo, I don't see any built-in methods for that. You'd have to write an SQL query to sum the 'load' field for all filed PIREPs. This is the part of Total Pax Carried (which I deleted) <tt>Total Passengers Carried: </tt><?php echo StatsData::TotalPaxCarried(); ?><br /> For the cargo thingy I will pass as I don't know this coding stuff and don't want to mess with SQL Quote
Nuclear Posted April 2, 2011 Report Posted April 2, 2011 Try passing the airline: StatsData::TotalPaxCarried('MER') That's how I tested it, see if it makes a difference. According to the documentation, passing the airline is optional, so I assume by not passing anything it returns the total for all airlines (which should be the same value if you only have one airline), but either I'm wrong or there's a bug in the method. Quote
Moderators Kyle Posted April 2, 2011 Moderators Report Posted April 2, 2011 Hey Michael, Just to clear up, I don't think you need the 's in in the VA code. It should be done like that.. <?php echo StatsData::TotalPaxCarried(MER); ?> and it will return the data in order of an VA. Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 Hey Michael, Just to clear up, I don't think you need the 's in in the VA code. It should be done like that.. <?php echo StatsData::TotalPaxCarried(MER); ?> and it will return the data in order of an VA. Told you, I was doing something weird. Thanks guys. But it still is the same Total Pax Carried: 104643 Quote
Tom Posted April 2, 2011 Report Posted April 2, 2011 Hey Michael, Just to clear up, I don't think you need the 's in in the VA code. It should be done like that.. Technically you should have them I believe, but it doesn't really matter Quote
Nuclear Posted April 2, 2011 Report Posted April 2, 2011 Hey Michael, Just to clear up, I don't think you need the 's in in the VA code. It should be done like that.. <?php echo StatsData::TotalPaxCarried(MER); ?> and it will return the data in order of an VA. I just tested it again and it works either with or without the quotes. I also tested StatsData::TotalPaxCarried() without passing any arguments and it still returned the same value (2945), so I'm not sure what's wrong with the OP. Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 I think it somehow takes into account my cargo flights as pax too Quote
Tom Posted April 2, 2011 Report Posted April 2, 2011 I think it somehow takes into account my cargo flights as pax too It does. Pax and cargo aren't stored separately, they're just stored in 'load' - this function just adds it all up. Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 Ahh finally Then I have to remove that Total Pax thingy from my main page. Cheers, Quote
Tom Posted April 2, 2011 Report Posted April 2, 2011 Ahh finally Then I have to remove that Total Pax thingy from my main page. Cheers, Well, if you're using separate airline codes for pax and cargo (which from reading your about page it looks so) you can just use <?php echo StatsData::TotalPaxCarried(MER); ?> for pax and <?php echo StatsData::TotalPaxCarried(somethingelse); ?> for cargo. Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 Hmm. We use same name different flight number. But I think later I will change the freighter codes to something else. Thank you. Quote
Nuclear Posted April 2, 2011 Report Posted April 2, 2011 Well, there is a way to do it using SQL: $query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'"; $result=DB::get_results($query); echo $result[0]->totalpax; This sums up the load for passenger flights only. This assumes that you have your cargo routes set as cargo flights. Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 Yay! Thank you so much Michael Quote
airmermaid Posted April 2, 2011 Author Report Posted April 2, 2011 I just would like to ask if this topic can be marked as SOLVED. I don't know how to do that. Cheers, Quote
Tom Posted April 2, 2011 Report Posted April 2, 2011 I just would like to ask if this topic can be marked as SOLVED. I don't know how to do that. Cheers, If you go and edit the first post you can add [sOLVED] to the topic title Quote
airmermaid Posted April 3, 2011 Author Report Posted April 3, 2011 Thanks Tom. I must remember using the full edit mode instead of fast reply Quote
Administrators Nabeel Posted April 3, 2011 Administrators Report Posted April 3, 2011 I just looked at the code, it only pulls the PAX type of 'P', so passenger flights. Make sure you haven't inadvertantly set a cargo flight to a pax type Quote
airmermaid Posted April 4, 2011 Author Report Posted April 4, 2011 Hi Nabeel, For pax I used the exact code Michael sent. For cargo instead I have modified it as .....WHERE `flighttype`='C'"; Quote
TAV1702 Posted April 5, 2011 Report Posted April 5, 2011 I have the exact same problem as the original author. I just two day ago set up a few cargo flights and my passenger count went through the roof with only 2 flights done. I am pulling the stats exactly how he did originally. And I thought it was odd so I went and looked at the schedules just to verify that they ARE infact selected as cargo flights and not charter or passenger. All the cargo flights are all selected as cargo. I do have two separate airlines set up. Neither of which does cargo specific schedules. Cargo flights just end up where they end up at in either airline. Quote
TAV1702 Posted April 5, 2011 Report Posted April 5, 2011 Well, there is a way to do it using SQL: $query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'"; $result=DB::get_results($query); echo $result[0]->totalpax; This sums up the load for passenger flights only. This assumes that you have your cargo routes set as cargo flights. And where did you put this little sql query at? In the stats data class? And if so where did you insert it at? Here is what I am looking at as we speak. public static function TotalPaxCarried($airline_code = '') { $key = 'total_pax_carried'; if ($airline_code != '') { $key .= '_' . $airline_code; } $total = CodonCache::read($key); if ($total === false) { $params = array('table' => TABLE_PREFIX . 'pireps', 'fields' => 'SUM(`load`) as `total`', 'where' => array('accepted' => PIREP_ACCEPTED, 'flighttype' => 'P'), ); if (!empty($airline_code)) { $params['where']['code'] = $airline_code; $params['group'] = 'code'; } $sql = DB::build_select($params); $results = DB::get_results($sql); if (!$results) { $total = 0; } else { $total = $results[0]->total; } CodonCache::write($key, $total, '15minute'); } return $total; } Quote
airmermaid Posted April 5, 2011 Author Report Posted April 5, 2011 Hi, In my site I have put it inside frontpage_main.tpl under sidebar entry where you also have Newest Pilots and such. This is the full code I am currently using. <h3 align="center">Statistics</h3> <table bgcolor="#d6d6d6" frame="border" align="center" bordercolor="#010854"> <tr align="left"><th> <div> <tt>Total Pilots: </tt><?php echo StatsData::PilotCount(); ?><br /> <tt>Total Pax Flights: </tt> <?php $query="SELECT COUNT(*) as totalfltp FROM `phpvms_pireps` WHERE `flighttype`='P'"; $result=DB::get_results($query); echo $result[0]->totalfltp; ?><br /> <tt>Total Cargo Flights: </tt> <?php $query="SELECT COUNT(*) as totalfltp FROM `phpvms_pireps` WHERE `flighttype`='C'"; $result=DB::get_results($query); echo $result[0]->totalfltp; ?><br /> <tt>Total Hours Flown: </tt><?php echo StatsData::TotalHours()?> <?php echo hours; ?><br /> <tt>Total Miles Flown: </tt><?php echo StatsData::TotalMilesFlown()?> <?php echo NM; ?><br /> <tt>Total a/c in Fleet: </tt><?php echo StatsData::TotalAircraftInFleet(); ?><br /> <tt>Total Flights Today: </tt><?php echo StatsData::totalflightstoday(); ?><br /> <tt> Total Pax Carried: </tt><?php $query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'"; $result=DB::get_results($query); echo $result[0]->totalpax; ?> <?php echo Persons; ?><br /> <tt>Total Cargo Carried: </tt><?php $query="SELECT SUM(`load`) as totalfreight FROM `phpvms_pireps` WHERE `flighttype`='C'"; $result=DB::get_results($query); echo $result[0]->totalfreight; ?> <?php echo Kgs; ?><br /></div> </th></tr></table> Hope it helps. 1 Quote
TAV1702 Posted April 5, 2011 Report Posted April 5, 2011 Hi, In my site I have put it inside frontpage_main.tpl under sidebar entry where you also have Newest Pilots and such. This is the full code I am currently using. Hope it helps. Thanks, I appreciate it. Quote
TAV1702 Posted April 5, 2011 Report Posted April 5, 2011 Well, I tried that and it echoed persons after the number which in my case stayed the same. I wonder if I should have deleted my cache and all that good stuff in the maint center to get the number to reflect accurately. Quote
airmermaid Posted April 6, 2011 Author Report Posted April 6, 2011 Well, I tried that and it echoed persons after the number which in my case stayed the same. I wonder if I should have deleted my cache and all that good stuff in the maint center to get the number to reflect accurately. I think it is because the name of the database in your VA is not "phpvms_pireps" but something else. Try calling it with the exact name. In my VA it is "phpvms_CEOpireps" Quote
Nuclear Posted April 6, 2011 Report Posted April 6, 2011 Well, I tried that and it echoed persons after the number which in my case stayed the same. I wonder if I should have deleted my cache and all that good stuff in the maint center to get the number to reflect accurately. Can you post the exact code you're using? The cache shouldn't make a difference; the code I posted is a direct SQL query, which is not cached, unlike the API calls, which do utilize caching. My way is not necessarily better, in fact it's worse in several ways, but it is one way to get the results. Quote
Administrators Nabeel Posted April 6, 2011 Administrators Report Posted April 6, 2011 Right, you also have to make sure the TABLE_PREFIX is correct: $sql = "SELECT * FROM ".TABLE_PREFIX."tablename"; Since some people change table prefixes Quote
TAV1702 Posted April 6, 2011 Report Posted April 6, 2011 Right, you also have to make sure the TABLE_PREFIX is correct: $sql = "SELECT * FROM ".TABLE_PREFIX."tablename"; Since some people change table prefixes Everything is default. I never change anything database related. It is how it was installed. Why mess witha piece of work that is proven to begin with and one of if not the best working around? And thanks for the help on this one guys. I appreciate it. This has been causing quite a buzz on my test site the last week or so. It was just kind of ironic you guys all started talking about it at about the same time I noticed the problem. Quote
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.