修复 PHP 8.4+ 中 PDO::MYSQL_ATTR_USE_BUFFERED_QUERY 的弃用警告 (#1922)

This commit is contained in:
猫东东
2025-11-27 09:05:18 +08:00
committed by GitHub
parent 7a3c86a110
commit 9364388035

View File

@@ -73,7 +73,14 @@ class Mysql extends Pdo
$config->password,
$options
);
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
if (class_exists('\Pdo\Mysql')) {
// 新版本写法
$pdo->setAttribute(\Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true);
} else {
// 兼容旧版本
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
if ($config->charset) {
$pdo->exec("SET NAMES '{$config->charset}'");