connection = new PDO( $dsn, $config['username'], $config['password'], $config['options'] ); } catch (PDOException $e) { throw new \Exception("数据库连接失败: " . $e->getMessage()); } } public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } public function getConnection() { return $this->connection; } }