fix: update koneksi database menggunakan normal user
This commit is contained in:
@@ -1,8 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$host_sekarang = $_SERVER['SERVER_NAME'];
|
||||||
|
|
||||||
|
if ($host_sekarang === 'localhost' || $host_sekarang === '127.0.0.1') {
|
||||||
$host = "localhost";
|
$host = "localhost";
|
||||||
$user = "root";
|
$user = "root";
|
||||||
$pass = "";
|
$pass = "";
|
||||||
$db = "webgis_db";
|
$db = "webgis_db";
|
||||||
|
} else {
|
||||||
|
// Gunakan Kredensial Normal User dari Coolify
|
||||||
|
$host = "mysql-webgis";
|
||||||
|
$user = "mysql"; // Menggunakan Normal User
|
||||||
|
$pass = "YN54ned6j7P6K7c76sLqh9ERUbm8xvhPFj31Mnt0yKPXxqrIhWICWlbJbJjUCfn7"; // Normal User Password
|
||||||
|
$db = "default";
|
||||||
|
}
|
||||||
|
|
||||||
// Connect to MySQL server first
|
// Connect to MySQL server first
|
||||||
$conn = new mysqli($host, $user, $pass);
|
$conn = new mysqli($host, $user, $pass);
|
||||||
@@ -12,7 +22,7 @@ if ($conn->connect_error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create database if not exists
|
// Create database if not exists
|
||||||
$conn->query("CREATE DATABASE IF NOT EXISTS `$db` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;");
|
// $conn->query("CREATE DATABASE IF NOT EXISTS `$db` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;");
|
||||||
|
|
||||||
// Select database
|
// Select database
|
||||||
$conn->select_db($db);
|
$conn->select_db($db);
|
||||||
@@ -45,4 +55,3 @@ if ($row['count'] == 0) {
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user