Jump to content

SQL Question


AFVA | Mitchell

Recommended Posts

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

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...