config = $config; try { // 连接数据库 parent::__construct($this->config->GetPdoDSN(), $this->config->getUser(), $this->config->getPassword()); // 设置错误模式为异常 $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { throw new Exception("连接数据库失败: " . $e->getMessage()); } } }