lanousbh Posted June 30, 2017 Report Posted June 30, 2017 Hi, I'm not the best at coding but I would like to know if anyone knows a function that will count all live flight from the acars db and put it in a number. For example if the acars map shows 6 flight I would like the function to show 6 Thanks Quote
tim260 Posted June 30, 2017 Report Posted June 30, 2017 Hi, If you send me a pm on here I could send you the code or even program your own customised page (for free of course). Just send me the details Yours, Tim Quote
tim260 Posted June 30, 2017 Report Posted June 30, 2017 For other users: Lanoush did it a different way himself but if you want to implement it into your ACARSData class you can use this. if you want to implement it into your ACARSData you can add this to your ACARSData.class.php public static function getLiveFlightCount($cot = '') { // make sure its not using flights that havent been updated by using cutoff time $cutofftime = (empty($cutofftime)) ? Config::Get('ACARS_LIVE_TIME') : $cot; //ternary operator instead of if argument to reduce lines $sql = 'SELECT COUNT(*) as total FROM ' . TABLE_PREFIX . 'acarsdata'; $sql .= ($cutofftime !== 0) ? ' WHERE DATE_SUB(NOW(), INTERVAL ' .$cutofftime .' MINUTE) <= `lastupdate`': ''; $result = DB::get_row($sql); return $result->total; } then on any page you could use echo ACARSData::getLiveFlightCount(); or you could of course add it to any of your pages as a variable in the module itself: $this->set('liveFlightCount',ACARSData::getLiveFlightCount()); // on the page then you could do: echo $liveFlightCount; 1 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.