Guest User

Untitled

a guest
Mar 2nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php
  2. echo "Initializing... <br>\n";
  3. echo "*************** <br>\n";
  4. $server = "localhost:3306";
  5. $username = "root";
  6. $password = "";
  7. $mysql_connection = mysql_connect($server, $username, $password);
  8. if (!$mysql_connection)
  9. {
  10. die ('Could not connect to mysql'.mysql_error());
  11. }
  12. else
  13. {
  14. echo "Connection MySQL established.<br>\n";
  15. }
  16. $mysql_database = mysql_select_db('midgard_test',$mysql_connection);
  17. if (!$mysql_database)
  18. {
  19. die ('Could not connect to database'.mysql_error());
  20. }
  21. {
  22. echo "Database selected successfully! <br>\n";
  23. }
  24.  
  25. $filename = 'wicom-sql-statements.txt';
  26. $sql_statements = file($filename);
  27. echo "File read... <br>\n";
  28.  
  29. $counter = 0;
  30. $total_counter = 0;
  31. foreach ($sql_statements as $line)
  32. {
  33. $counter++;
  34. $total_counter++;
  35. if ($counter == 50)
  36. {
  37. echo "*****<br>\n";
  38. echo "Counter hit 50 - SLEEPING for 5 seconds <br>\n";
  39. echo "*****<br>\n";
  40. sleep(5);
  41. $optimize = mysql_query('OPTIMIZE TABLE record_extension');
  42. if (!$optimize)
  43. {
  44. echo "Could not optimize... <br>\n";
  45. }
  46. else
  47. {
  48. echo "Table optimized. <br>\n";
  49. }
  50. $counter = 0;
  51. echo "Counter RESET<br>\n";
  52. echo "*****<br>\n";
  53. }
  54. echo "[".$total_counter."/8646] Line read.<br>\n";
  55. $query = mysql_query($line);
  56. if (!$query)
  57. {
  58. die('ERROR, COULD NOT SUBMIT QUERY'.mysql_error());
  59. }
  60. usleep(100000);
  61. }
  62.  
  63. echo "<br>\n*****<br>\n";
  64. echo "We are done here <br>\n";
  65. echo "*****<br>\n";
  66. fclose($file);
  67. $mysql_close_connection = mysql_close($mysql_connection);
  68. if (!$mysql_close_connection)
  69. {
  70. die('Could not close MySQL connection');
  71. }
  72. else
  73. {
  74. echo "MySQL connection closed! <br>\n";
  75. }
  76. ?>
Add Comment
Please, Sign In to add comment