Jump to content

moving/deleting inactive pilots


joeri

Recommended Posts

I had asked the same question a while back, and pretty much got the answer of "No possible way". However, my new idea would be to re-assign the PIREPs to another "pilot" who would actually be an inactive bot, that would retain all of the hours but allow me to open up pilot ID slots. Ya know?

Anyone have any ideas for either of the ideas? (If your answer is "no possible way", please keep it to yourself as this is now a brainstorming post and not one for naysayers!) ;):D

Link to comment
Share on other sites

  • Moderators

The file you need to modify is Core>Common>PilotData.class.php

In my file its around line 513 but yours may be different,

/**
* Completely delete a pilot
*
* @param int $pilotid Pilot ID
* @return mixed This is the return value description
*
*/
public static function deletePilot($pilotid) {

$sql = array();
unset(self::$pilot_data[$pilotid]);

$tables = array(
'acarsdata', 'bids', 'pirepcomments', 'pireps',
'fieldvalues', 'groupmembers', 'pilots'
);

foreach ($tables as $table) {
$sql = 'DELETE FROM '.TABLE_PREFIX.$table.' WHERE `pilotid`='.$pilotid;
$res = DB::query($sql);
}

return true;
}

Thats the code so just take the pireps and pirepcomments out of the array.

NOT TESTED please use at your peril.

Link to comment
Share on other sites

  • Members

Most propably you will get an error that the function is not found

If i wanted to delete the pilot but not the pireps i would create a pilot with a name "Retired Pilot" and would run an sql query to update the pireps to that pilot and then delete the others.

Out of curiosity why would you delete the pilots and keep the pireps ?

Link to comment
Share on other sites

  • Moderators

with phpvms all pireps are linked to a pilot so iff lets say i have a pilot with 500 pireps all for 5 hours each i would lose 2500 hours in totals so in the end the statistics wil not reflect the real flown hours or pireps of the airline insted it show what curently is in the database

Link to comment
Share on other sites

  • 1 year later...
  • Moderators

As it was stated before, you can comment out the code that delete's the pilot pireps. Open your PilotData.class.php, find this:

public static function deletePilot($pilotid)
{
 $sql = array();
 unset(self::$pilot_data[$pilotid]);

 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'acarsdata WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'bids WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'pireps WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'pilots WHERE pilotid='.$pilotid;

 # These SHOULD delete on cascade, but incase they don't
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'fieldvalues WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'groupmembers WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'pirepcomments WHERE pilotid='.$pilotid;

 foreach($sql as $query)
 {
  $res = DB::query($query);
 }

 if(DB::errno() != 0)
  return false;

 return true;
}

and replace it with this:

public static function deletePilot($pilotid)
{
 $sql = array();
 unset(self::$pilot_data[$pilotid]);

 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'acarsdata WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'bids WHERE pilotid='.$pilotid;
 //$sql[] = 'DELETE FROM '.TABLE_PREFIX.'pireps WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'pilots WHERE pilotid='.$pilotid;

 # These SHOULD delete on cascade, but incase they don't
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'fieldvalues WHERE pilotid='.$pilotid;
 $sql[] = 'DELETE FROM '.TABLE_PREFIX.'groupmembers WHERE pilotid='.$pilotid;
 //$sql[] = 'DELETE FROM '.TABLE_PREFIX.'pirepcomments WHERE pilotid='.$pilotid;

 foreach($sql as $query)
 {
  $res = DB::query($query);
 }

 if(DB::errno() != 0)
  return false;

 return true;
}

I have not tested it. You can run it on a backup website first.

Link to comment
Share on other sites

  • Moderators

If you mean phpvms admin center, yes but all the pilot's pireps will be deleted if you do not use the code which was stated above. If you mean phpmyadmin, yes but not all of us know how to use it and it's better to suggest ways and do things through the admin center. Bare in mind that you don't have to delete the pilot from the pilot's database table only. You have to delete all the pilot data such as his acarsdata, his bids, his pesmissions and plenty other in order to have a "clear" database.

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...