Advertisement
kura2yamato

fix

Jan 9th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //koneksi
  4. $db = "rand_bioskop";
  5. $con = new mysqli("localhost", "root", "gundam1981", $db); //mysqli
  6. //coba bikin database sendiri dan isi table2 terserah kamu. anggap ada 5
  7. // masukkan view didalamnya anggap ada 2
  8. // Check connection
  9. if ($con->connect_errno) {
  10.     echo "Failed to connect to MySQL: " . $mysqli->connect_error;
  11. }
  12.  
  13. /* * **
  14.   buatlah  fungsi
  15.   extract semua table (only) dalam database..
  16.   masukkan dalam array $aTable yg isinya hanya 5 (jgn 2)
  17.  * *** */
  18. $sql = "show full tables FROM `{$db}` where Table_Type != 'VIEW'";
  19. if ($result = $con->query($sql)) {
  20.     while ($row = $result->fetch_row()) {
  21.         //echo "Table: {$row[0]}\n";
  22. //===========REPAIR TIDAK DILAKUKAN DISINI
  23.         //repair table using MYISAM Only. tested and work!
  24.         //$sql="REPAIR TABLE $row[0] USE_FRM";
  25.         // $con->query($sql);
  26.         // echo "\nRepair:$row[0]";
  27.         // var_dump($con->query($sql));
  28.         $aTable[] = $row[0];
  29.     }
  30. } else {
  31.     printf("Errormessage: %s\n", $con->error);
  32.     die;
  33. }
  34.  
  35. //===lakukan proses repair/optimize
  36. foreach ($aTable as $table) {
  37.     $sql = "OPTIMIZE TABLE `{$table}` ; ";
  38.     $con->query($sql);
  39.     echo "\nRepair:$table"
  40.     . "\n$sql\n";
  41.     var_dump($con->query($sql));
  42. }
  43.  
  44. /*
  45. Buatlah sesingkat mungkin
  46. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement