From efa1d7f514c6a266a209ef23bd1c15e15f335cd9 Mon Sep 17 00:00:00 2001 From: "2368302435@qq.com" <2368302435@qq.com> Date: Wed, 17 Apr 2024 03:32:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A1=A8=E3=80=81=E9=80=89=E6=8B=A9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8=E5=AD=97=E6=AE=B5=E6=8E=A5=E5=8F=A3=E9=9D=9E?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/ba/TableManager.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extend/ba/TableManager.php b/extend/ba/TableManager.php index d385ae04..a649eb9b 100644 --- a/extend/ba/TableManager.php +++ b/extend/ba/TableManager.php @@ -67,8 +67,9 @@ class TableManager public static function getTableList(?string $connection = null): array { $tableList = []; - $connection = self::getConnectionConfig($connection); - $tables = Db::query("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema = ? ", [$connection['database']]); + $config = self::getConnectionConfig($connection); + $connection = self::getConnection($connection); + $tables = Db::connect($connection)->query("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema = ? ", [$config['database']]); foreach ($tables as $row) { $tableList[$row['TABLE_NAME']] = $row['TABLE_NAME'] . ($row['TABLE_COMMENT'] ? ' - ' . $row['TABLE_COMMENT'] : ''); } @@ -87,14 +88,15 @@ class TableManager if (!$table) return []; $table = self::tableName($table, true, $connection); - $connection = self::getConnectionConfig($connection); + $config = self::getConnectionConfig($connection); + $connection = self::getConnection($connection); // 从数据库中获取表字段信息 // Phinx 目前无法正确获取到列注释信息,故使用 sql $sql = "SELECT * FROM `information_schema`.`columns` " . "WHERE TABLE_SCHEMA = ? AND table_name = ? " . "ORDER BY ORDINAL_POSITION"; - $columnList = Db::query($sql, [$connection['database'], $table]); + $columnList = Db::connect($connection)->query($sql, [$config['database'], $table]); $fieldList = []; foreach ($columnList as $item) {