Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. mysql_connect();
  4.  
  5. // Get the last id of player
  6. $lastPlayerId = mysql_fetch_array(mysql_query("SELECT id FROM players DESC"))[0];
  7.  
  8. // Get the last id of account
  9. $lastAccountId = mysql_fetch_array(mysql_query("SELECT id FROM accounts DESC"))[0];
  10.  
  11. // Connect to the other database
  12.  
  13. //disconnect from the first
  14. mysql_connect();
  15.  
  16. // Start updating the ids of players
  17. $i = 0;
  18. for(;;) {
  19.     if (mysql_error())
  20.         break;
  21.        
  22.     $i++;
  23.     $newPId = $lastPlayerId + $i;
  24.     $newAId = $lastAccountId + $i;
  25.    
  26.     // Update the foreign dependent tables
  27.     mysql_query("UPDATE accounts SET id = ".$newAId." WHERE id = ".$i."");
  28.    
  29.     mysql_query("UPDATE players SET account_id = ".$newAId." WHERE id = ".$i."");
  30.    
  31.     mysql_query("UPDATE players SET id = ".$newPId." WHERE id = ".$i."");
  32.     mysql_query("UPDATE player_skill SET player_id = ".$i." WHERE id = ".$newPId."");
  33.     mysql_query("UPDATE player_items SET player_id = ".$i." WHERE id = ".$newPId."");
  34.     mysql_query("UPDATE player_depotitems SET player_id = ".$i." WHERE id = ".$newPId."");
  35.     mysql_query("UPDATE player_storage SET player_id = ".$i." WHERE id = ".$newPId."");
  36. }
  37.  
  38.  
  39. // Merge them all!
  40.  
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement