-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrop_alltable_db.php
More file actions
45 lines (37 loc) · 910 Bytes
/
drop_alltable_db.php
File metadata and controls
45 lines (37 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
// koneksi ke database di file koneksi.php
include "koneksi.php";
// inisialisasi timezone
date_default_timezone_set('Asia/Jakarta');
$cek=0;
mysqli_autocommit($kon, false);
$sql1 = "SET foreign_key_checks = 0";
$result1 = mysqli_query($kon,$sql1);
if (!$result1) {
$cek=$cek+1;
}
$sql2 = "SHOW TABLES";
$result2 = mysqli_query($kon, $sql2);
while ($row = mysqli_fetch_row($result2)) {
$sql3 = "DROP TABLE IF EXISTS .$row[0]";
$result3 = mysqli_query($kon,$sql3);
if (!$result3) {
$cek=$cek+1;
}
}
$sql4 = "SET foreign_key_checks = 1";
$result4 = mysqli_query($kon,$sql4);
if (!$result4) {
$cek=$cek+1;
}
if ($cek==0){
mysqli_commit($kon);
echo ("<script LANGUAGE='JavaScript'>
window.alert('Berhasil Menghapus All Tabel');
window.location.href='index.php';
</script>");
}else{
mysqli_rollback($kon);
}
mysqli_close($kon);
?>