__db = $db; }
else $this->__db = new \siaupheng\fonia3\DB\MySQL();
$this->__db->Query("SELECT TABLE_NAME,ENGINE,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='".$this->__db->getDBName()."' AND TABLE_TYPE='BASE TABLE'");
while ($this->__db->Next()) {
$this->__atabel[] = array($this->__db->Row("TABLE_NAME"), ' ('.$this->__db->Row("ENGINE").')',' ('.uang($this->__db->Row("TABLE_ROWS")).' Records)');
}
}
public function ignore_table() {
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$this->__aignore = $tmp_arr;
}
private function _check_db($atabel=array()) {
$hasil = "";
if (!in_array($atabel[0], $this->__aignore)) {
$pesan = "OK";
$this->__db->Query("CHECK TABLE ".$atabel[0]);
if ($this->__db->Next()) {
if (strtoupper($this->__db->Row("Msg_text"))<>"OK") {
$pesan = "ERROR";
$this->__db->Query("REPAIR TABLE ".$atabel[0]);
if ($this->__db->Next()) {
if (strtoupper($this->__db->Row("Msg_text"))=="OK") {
$pesan .= " -> FIXED";
}
}
}
}
$hasil = $atabel[0] . $atabel[2] ." ... ". $pesan ."
";
}
return $hasil;
}
public function count_db() {
return count($this->__atabel);
}
public function check_db() {
$hasil = "=== CEK DATABASE ===
";
for ($n=0;$n__atabel);$n++) {
$hasil .= $this->_check_db($this->__atabel[$n]);
}
return $hasil;
}
public function check_db_step($n) {
$hasil .= $this->_check_db($this->__atabel[$n]);
}
public function repair_db() {
$hasil = "=== REPAIR DATABASE ===
";
for ($n=0;$n__atabel);$n++) {
if (!in_array($this->__atabel[$n][0], $this->__aignore)) {
$pesan = "OK";
$this->__db->Query("REPAIR TABLE ".$this->__atabel[$n][0]);
while ($this->__db->Next()) {
$pesan = (strtoupper($this->__db->Row("Msg_text"))=="OK") ? "OK" : "ERROR";
}
$hasil .= $this->__atabel[$n][0] . $this->__atabel[$n][1] ." ... ". $pesan ."
";
}
}
return $hasil;
}
public function optimize_db() {
$hasil = "=== OPTIMALISASI DATABASE ===
";
for ($n=0;$n__atabel);$n++) {
if (!in_array($this->__atabel[$n][0], $this->__aignore)) {
$pesan = "OK";
$this->__db->Query("OPTIMIZE TABLE ".$this->__atabel[$n][0]);
while ($this->__db->Next()) {
$pesan = (strtoupper($this->__db->Row("Msg_text"))=="OK" || strtoupper($this->__db->Row("Msg_text"))=="TABLE IS ALREADY UP TO DATE") ? "OK" : "ERROR";
}
$hasil .= $this->__atabel[$n][0] . $this->__atabel[$n][1] ." ... ". $pesan ."
";
}
}
return $hasil;
}
}
?>