Tato123 Posted March 28, 2014 Report Posted March 28, 2014 <?php class HubStats extends Codondata { public static function Pilots($icao) { //Pilot details $query = "SELECT * FROM ".TABLE_PREFIX."pilots WHERE hub = '".$icao."'"; return DB::get_results($query); } public static function CountPilots($icao) { //Number of pilots $query = "SELECT COUNT(pilotid) as count FROM ".TABLE_PREFIX."pilots WHERE hub = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function CountFlights($icao) { //Number of flights total $query = "SELECT COUNT(pirepid) as count FROM ".TABLE_PREFIX."pireps WHERE arricao = '".$icao."' OR depicao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function CountFlightsFrom($icao) { //Number of flights departing $query = "SELECT COUNT(pirepid) as count FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function CountFlightsTo($icao) { //Number of flights arriving $query = "SELECT COUNT(pirepid) as count FROM ".TABLE_PREFIX."pireps WHERE arricao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function FlightsDetails($icao, $limit=10) { //Details of latest (10) flights $query = "SELECT * FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."' ORDER BY submitdate DESC LIMIT ".intval($limit); return DB::get_results($query); } public static function CountRoutes($icao) { //Count schedules $query = "SELECT COUNT(id) as count FROM ".TABLE_PREFIX."schedules WHERE depicao = '".$icao."' OR arricao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function CountRoutesFrom($icao) { //Count schedules departing $query = "SELECT COUNT(id) as count FROM ".TABLE_PREFIX."schedules WHERE depicao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function CountRoutesTo($icao) { //Count schedules arriving $query = "SELECT COUNT(id) as count FROM ".TABLE_PREFIX."schedules WHERE arricao = '".$icao."'"; $results = DB::get_row($query); return $results->count; } public static function TotalMiles($icao) { //Count miles flown $query = "SELECT SUM(distance) as miles FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."'"; $result = DB::get_row($query); return $result->miles; } public static function TotalMilesFrom($icao) { //Count miles flown departing $query = "SELECT SUM(distance) as miles FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."'"; $result = DB::get_row($query); return $result->miles; } public static function TotalMilesTo($icao) { //Count miles flown arriving $query = "SELECT SUM(distance) as miles FROM ".TABLE_PREFIX."pireps WHERE arricao = '".$icao."'"; $result = DB::get_row($query); return $result->miles; } public static function TotalHours($icao) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."' OR arricao = '".$icao."'"; $result = DB::get_row($query); return $result->hours; } public static function TotalHoursFrom($icao) { //Count total hours departing $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE depicao = '".$icao."'"; $result = DB::get_row($query); return $result->hours; } public static function TotalHoursTo($icao) { //Count total hours arriving $query = "SELECT SUM(flighttime) as hours FROM ".TABLE_PREFIX."pireps WHERE arricao = '".$icao."'"; $result = DB::get_row($query); return $result->hours; } public static function TotalFuelUsed($icao) { //Count total fuel used arriving $query = "SELECT SUM(fuelused) as fuel FROM ".TABLE_PREFIX."pireps WHERE arricao = '".$icao."'"; $result = DB::get_row($query); return $result->fuel; } } ?> TPL <td>Numero Voli in Arrivo</td> <td><?php echo HubStats::CountFlightsTo('LIMF'); ?></td> </tr> Quote
Moderators servetas Posted March 28, 2014 Moderators Report Posted March 28, 2014 Do you get any error? Quote
Tato123 Posted March 28, 2014 Report Posted March 28, 2014 no error. The sitedon't show the number Quote
flyalaska Posted March 28, 2014 Report Posted March 28, 2014 What version are you on? I have the same problem. Quote
Moderators servetas Posted March 28, 2014 Moderators Report Posted March 28, 2014 For some reason, you don't call it correctly. Use the following code and let me know if it works. <?php echo HubStatsData::CountFlightsTo('LIMF'); ?> Quote
Tom Posted March 28, 2014 Author Report Posted March 28, 2014 For some reason, you don't call it correctly. Use the following code and let me know if it works. <?php echo HubStatsData::CountFlightsTo('LIMF'); ?> That wouldn't work as the class is "HubStats" not "HubStatsData" If you run the SQL in phpmyadmin does it return correctly? "SELECT COUNT(pirepid) as count FROM phpvms_pireps WHERE arricao = 'LIMF'" Quote
Tato123 Posted March 29, 2014 Report Posted March 29, 2014 Yes Tom, the query work and return number 4 Quote
Tom Posted March 29, 2014 Author Report Posted March 29, 2014 If you wrap it in a try/catch does it give you an error? Quote
Tato123 Posted March 29, 2014 Report Posted March 29, 2014 no error Is influent the php version ? Quote
Tom Posted March 29, 2014 Author Report Posted March 29, 2014 no error Is influent the php version ? I don't expect it would be because of the PHP version, especially not if only 1 of the functions fails when they're pretty much the same process. It's difficult to work out what's wrong if your server returns no error without actually looking at it all. Quote
Strider Posted March 29, 2014 Report Posted March 29, 2014 Try looking at the error_log, errors that dont show, usually show in that. Quote
flyalaska Posted April 5, 2014 Report Posted April 5, 2014 Only thing I can suggest is that you don't have phpvms_ as your table prefix. Other than that, you could always do $startdate = date("Y-m-01"); $enddate = date("Y-m-t"); HubStats::TotalHoursBetweenDates('PANC', date("Y-m-01"), date("Y-m-t")); Shouldn't make a difference but give it shot. EDIT: You might have to set your timezone: date_default_timezone_set('Europe/London'); Change as necessary of course. Have some progress. Its not pulling the monthly stats correctly. It's the 4th of the month now way we have that many hours already. HubClass file public static function TotalCargoBetweenDates($icao, $startdate, $enddate) { //Count total cargo $query = "SELECT SUM(cargo) as cargo FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND flighttype = 'C' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) <= '$enddate' AND accepted = '1'"; $result = DB::get_row($query); return $result->cargo; } php file <?php echo HubStats::TotalHoursBetweenDates('CYQH', date("Y-m-01"), date("Y-m-t"));?> Not sure why it showing data now and not before. Quote
jrodosu Posted May 11, 2016 Report Posted May 11, 2016 Is there a simple code that also shows hubs stats for the current month? For example, today my Hubs show data for all time, but I would also like to see activity for this month as well. Thanks, Jay 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.