diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 390cb953df717ac12b3887caaea4ec68ebdce061..f41d951d23e3d176c94531343fff07b8ab05c2d0 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -435,16 +435,19 @@ class Crud extends Command $modelName = $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table; $modelTableType = 'table'; $modelTableTypeName = $modelTableName = $modelName; - $modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); - if (!$modelTableInfo) { - $modelTableType = 'name'; - $modelTableName = $prefix . $modelName; + $modelTableInfo = null; + if (!$input->getOption('delete')) { $modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); if (!$modelTableInfo) { - throw new Exception("table not found"); + $modelTableType = 'name'; + $modelTableName = $prefix . $modelName; + $modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); + if (!$modelTableInfo) { + throw new Exception("table not found"); + } } + $modelTableInfo = $modelTableInfo[0]; } - $modelTableInfo = $modelTableInfo[0]; $relations = []; //检查关联表 @@ -1069,7 +1072,7 @@ class Crud extends Command } //表注释 - $tableComment = $modelTableInfo['Comment']; + $tableComment = $modelTableInfo ? $modelTableInfo['Comment'] : ''; $tableComment = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) . '管理' : $tableComment; $modelInit = '';