Moderators joeri Posted January 13, 2014 Moderators Report Share Posted January 13, 2014 hey all i am not sure iff it has ever come up already but i could not rmember or find it. i want to delete pilots who are not flying annymore but i want to keep theyr pireps does annybody ever found a solution for that? Quote Link to comment Share on other sites More sharing options...
hollinst Posted January 14, 2014 Report Share Posted January 14, 2014 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!) Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted January 14, 2014 Author Moderators Report Share Posted January 14, 2014 i was thinking something simular Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted January 14, 2014 Moderators Report Share Posted January 14, 2014 Go to the pilot admin and comment out the code that deleted pireps, give me 5 minutes and i will post it. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted January 14, 2014 Moderators Report Share Posted January 14, 2014 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. Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted January 14, 2014 Members Report Share Posted January 14, 2014 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 ? Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted January 14, 2014 Author Moderators Report Share Posted January 14, 2014 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 Quote Link to comment Share on other sites More sharing options...
TennShadow Posted July 30, 2015 Report Share Posted July 30, 2015 Hey, I know this post is almost 2 years old but has anyone ever figured out a workaround to this? I too would like to remove pilots without losing all the records. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted July 30, 2015 Moderators Report Share Posted July 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted July 30, 2015 Report Share Posted July 30, 2015 Thanks for the reply. I read that above but nobody responded that they tried that and what the results were. So, I just assumed it was never tested and / or didn't work as expected. I'll add this to my dev site and give it a go. Thanks again! Quote Link to comment Share on other sites More sharing options...
OA01 Posted July 30, 2015 Report Share Posted July 30, 2015 Can't you just delete the pilot via PHPAdmin? Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted July 30, 2015 Moderators Report Share Posted July 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted July 30, 2015 Report Share Posted July 30, 2015 I commented out those two lines on my DEV site and it seems to work fine. I've ran the maintenance script a couple times and so far so good. Has anyone been using this method for a while? I'm just wondering if I'm overlooking any long term effects by doing this? Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted July 30, 2015 Moderators Report Share Posted July 30, 2015 Personally, i suspect that the only problem with this will be the thing that the submitted by will be empty whenever someone reaches a pirep which has been flown by a pilot who has been deleted from the system. Quote Link to comment Share on other sites More sharing options...
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.