From b6b690edb3704f50ff575418e0916123f715429b Mon Sep 17 00:00:00 2001 From: augushong Date: Sun, 1 Feb 2026 00:22:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(tools/db):=20=E5=9C=A8=E8=A1=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=8F=8F=E8=BF=B0=E4=B8=AD=E6=98=BE=E7=A4=BA=E8=A1=A8?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/tools/db/ToolsDbDescBase.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/extend/base/common/command/tools/db/ToolsDbDescBase.php b/extend/base/common/command/tools/db/ToolsDbDescBase.php index ae62c45..d8ceff5 100644 --- a/extend/base/common/command/tools/db/ToolsDbDescBase.php +++ b/extend/base/common/command/tools/db/ToolsDbDescBase.php @@ -54,6 +54,32 @@ class ToolsDbDescBase extends Command $output->writeln('' . str_repeat('=', 60) . ''); $output->writeln(''); + $tableComment = ''; + try { + $escaped = addcslashes($fullTableName, "\\_%"); + $rows = Db::connect($connection)->query("SHOW TABLE STATUS LIKE '$escaped'"); + if (!empty($rows)) { + $tableComment = (string)($rows[0]['Comment'] ?? ''); + } + } catch (\Throwable $e) { + } + + if ($tableComment === '') { + try { + $rows = Db::connect($connection)->query("SHOW CREATE TABLE `$fullTableName`"); + if (!empty($rows)) { + $create = $rows[0]['Create Table'] ?? ''; + if ($create !== '' && preg_match("/COMMENT='(.*?)'/s", $create, $matches)) { + $tableComment = stripcslashes($matches[1]); + } + } + } catch (\Throwable $e) { + } + } + + $output->writeln('表注释:' . $tableComment); + $output->writeln(''); + $columns = Db::connect($connection)->query("SHOW FULL COLUMNS FROM `$fullTableName`"); if (empty($columns)) {