Add k3s cluster expansion documentation and scripts
- Complete expansion guide for 2/4/6 node scenarios - Quick join scripts for worker and master nodes - Health check and diagnostic scripts - Quick reference card for common operations
This commit is contained in:
22
php-test/Database.php
Normal file
22
php-test/Database.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
class Database {
|
||||
private static ?PDO $instance = null;
|
||||
|
||||
public static function getConnection(): PDO {
|
||||
if (self::$instance === null) {
|
||||
try {
|
||||
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET;
|
||||
self::$instance = new PDO($dsn, 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) {
|
||||
die("数据库连接失败: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user