SQL Question

I want to modify:

public static function getAircraftInfo($reg)
           {
               $reg = DB::escape($reg);

               return DB::get_row('SELECT * FROM '.TABLE_PREFIX.'aircraft 
                                   WHERE `registration` ='.$reg
                                   );
           }

so it will return the hours as well..

I have no idea how I am going to this so can someone please provide the code.

Thanks,

Mitch

There is no record for total flight hours for an aircraft in the aircraft table, or anywhere else. You will need to create a sql call to the pireps table to get the total hours for an aircraft. Something like ->

public function get_AircraftHours($id) {

           $query = 'SELECT SUM(flighttime) AS total FROM '.TABLE_PREFIX."pireps WHERE aircraft='$id'";

           $result = DB::get_row($query);

           return $result->total;
       }

The “$id” variable has to be the database id of the aircraft, not the registration as it is recorded that way in the pireps table.

There’s a function which does that already in statsdata

There’s a function which does that already in statsdata

Sorry, but I don’t see it…

http://docs.phpvms.net/api/codon_core/StatsData.html#AircraftUsage

http://github.com/ns…class.php#L325

Ah, I see said the blind man.