- sogoctl: supervisor avec health checks et restart auto - sogoway: gateway HTTP, auth JWT, routing par hostname - sogoms-db: microservice MariaDB avec pool par application - Protocol IPC Unix socket JSON length-prefixed - Config YAML multi-application (prokov) - Deploy script pour container Alpine gw3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* Connexion à la base de données (Singleton)
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
class Database
|
|
{
|
|
private static ?PDO $instance = null;
|
|
|
|
public static function getInstance(): PDO
|
|
{
|
|
if (self::$instance === null) {
|
|
try {
|
|
self::$instance = new PDO(
|
|
sprintf('mysql:host=%s;dbname=%s;charset=utf8mb4', DB_HOST, DB_NAME),
|
|
DB_USER,
|
|
DB_PASS,
|
|
[
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
|
PDO::ATTR_EMULATE_PREPARES => false,
|
|
]
|
|
);
|
|
} catch (PDOException $e) {
|
|
Response::error('Database connection failed', 500);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
return self::$instance;
|
|
}
|
|
|
|
// Empêcher le clonage et la désérialisation
|
|
private function __construct() {}
|
|
private function __clone() {}
|
|
public function __wakeup() {}
|
|
}
|