Files
willes_AI/db.php
2025-10-12 00:07:59 +02:00

24 lines
608 B
PHP

<?php
function getConnection() {
$host = 'localhost';
$port = 3306;
$db = 'ai_email';
$user = 'aimail';
$pass = 'Test123';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;port=$port;dbname=$db;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
return new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
die("Database connection failed: " . $e->getMessage());
}
}
?>