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)) {