';
}
}
// Fetch Inventory
$inventory = [];
try {
$pdo = db();
// Create table if it doesn't exist (first run safety)
$pdo->exec("CREATE TABLE IF NOT EXISTS inventory (
id INT AUTO_INCREMENT PRIMARY KEY,
sku VARCHAR(50) NOT NULL UNIQUE,
name VARCHAR(255) NOT NULL,
size VARCHAR(10) NOT NULL,
price DECIMAL(10,2) NOT NULL DEFAULT 0.00,
stock INT NOT NULL DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
$stmt = $pdo->query("SELECT * FROM inventory ORDER BY created_at DESC");
$inventory = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Silent fail on read if DB not ready, or show empty
}
?>
Inventory |