35776-vm/db/db_setup.php
2025-11-16 17:25:40 +00:00

23 lines
722 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS patients (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
date_of_birth DATE NOT NULL,
gender VARCHAR(10) NOT NULL,
contact_number VARCHAR(20) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);";
$pdo->exec($sql);
// You can add a success message here if running from CLI
// echo "Table 'patients' created successfully (if it didn't exist).";
} catch (PDOException $e) {
// In a real app, you'd log this error, not display it
die("DB ERROR: " . $e->getMessage());
}