31 lines
779 B
PHP
31 lines
779 B
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
function setup_database() {
|
|
try {
|
|
$pdo = db();
|
|
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS members (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(255) NOT NULL,
|
|
nik VARCHAR(20) NOT NULL UNIQUE,
|
|
address TEXT,
|
|
phone VARCHAR(20),
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);";
|
|
|
|
$pdo->exec($sql);
|
|
|
|
// You can add more table creations here in the future
|
|
|
|
} catch (PDOException $e) {
|
|
// In a real app, you'd want to log this error
|
|
// For this example, we'll just output it.
|
|
die("DB setup failed: " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
// Run the setup
|
|
setup_database();
|