Initial commit

This commit is contained in:
2026-04-12 02:20:01 +02:00
commit 6c3e922080
8 changed files with 505 additions and 0 deletions

34
db.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
require "config.php";
function db_connect(): PDO
{
static $pdo = null;
if ($pdo !== null) {
return $pdo;
}
try {
$pdo = new PDO(CONFIG_DB_DSN, CONFIG_DB_USER, CONFIG_DB_PASSWORD);
} catch (PDOException $e) {
exit("Errore connessione database: " . $e->getMessage());
}
return $pdo;
}
function db_query(string $query, array $params = []): array
{
$pdo = db_connect();
try {
$stmt = $pdo->prepare($query);
$stmt->execute($params);
return $stmt->fetchAll();
} catch (PDOException $e) {
exit("Errore connessione database: " . $e->getMessage());
}
}
?>