Import SQL Langsung Dari Server Lain
<?php
$conn = new mysqli('localhost', 'root', '', 'e-sembako_offline');
//hapus table
$conn->query('SET foreign_key_checks = 0');
if ($result = $conn->query("SHOW TABLES")) {
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$conn->query('DROP TABLE IF EXISTS ' . $row[0]);
}
}
//tambah table
$query = '';
$sqlScript = file('https://abcde.com/public/database_backup.sql');
foreach ($sqlScript as $line) {
$startWith = substr(trim($line), 0, 2);
$endWith = substr(trim($line), -1, 1);
if (empty($line) || $startWith == '--' || $startWith == '/*' || $startWith == '//') {
continue;
}
$query = $query . $line;
if ($endWith == ';') {
mysqli_query($conn, $query) or die('<div class="error-response sql-import-response">Problem in executing the SQL query <b>' . $query . '</b></div>');
$query = '';
}
}
echo '<div class="success-response sql-import-response">SQL file imported successfully</div>';
?>
<script>
alert("Mengambil Dari Server Online Berhasil , Silahkan Cek")
</script>
<script>
window.location = 'sinkron'
</script>
Lanjut Part : 1
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1