From fb5972dd2cb8e6baef3dae3b3524609ce647cd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=8F=E9=A9=AC?= <179906767@qq.com> Date: Fri, 9 Sep 2022 03:23:40 +0000 Subject: [PATCH] =?UTF-8?q?update=20application/admin/command/Crud.php.=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9A=E5=88=A0=E9=99=A4=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E9=9C=80=E8=A6=81=E5=BC=BA=E5=88=B6=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E8=A1=A8=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E5=9C=A8=E5=88=A0=E9=99=A4=E5=89=8D=E5=B7=B2=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE=E8=A1=A8=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E2=80=9Ctable=20not=20foun?= =?UTF-8?q?d=E2=80=9D=E5=AF=BC=E8=87=B4=E5=88=A0=E9=99=A4=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复:增加删除模式判断,如果是删除模式,无需读取数据表 Signed-off-by: 苏小马 <179906767@qq.com> --- application/admin/command/Crud.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 390cb953d..f41d951d2 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 = ''; -- Gitee