View difference between Paste ID: Xr8PYYas and sitWZ7SN
SHOW: | | - or go back to the newest paste.
1
<?php
2
3-
$con= new mysqli("localhost","root","","my_db");//mysqli
3+
4
$db = "rand_bioskop";
5
$con = new mysqli("localhost", "root", "gundam1981", $db); //mysqli
6-
 // Check connection
6+
7-
 if ($con->connect_errno) {
7+
8
// Check connection
9
if ($con->connect_errno) {
10-
//LIST ALL TABLE
10+
11-
$sql= "show full tables FROM my_db where Table_Type != 'VIEW'";
11+
12-
$result = $con->query($sql);
12+
13-
while ($row =  $result->fetch_row()) {
13+
/* * **
14-
    echo "Table: {$row[0]}\n";
14+
  buatlah  fungsi
15-
    //repair table using MYISAM Only. tested and work!
15+
  extract semua table (only) dalam database..
16-
    $sql="REPAIR TABLE $row[0] USE_FRM";
16+
  masukkan dalam array $aTable yg isinya hanya 5 (jgn 2)
17-
     $con->query($sql);
17+
 * *** */
18-
    echo "\nRepair:$row[0]";
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-
/****
22+
//===========REPAIR TIDAK DILAKUKAN DISINI
23-
buatlah  fungsi
23+
        //repair table using MYISAM Only. tested and work!
24-
extract semua table (only) dalam database..
24+
        //$sql="REPAIR TABLE $row[0] USE_FRM";
25-
masukkan dalam array $aTable yg isinya hanya 5 (jgn 2)
25+
        // $con->query($sql);
26-
*****/
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
*/