From 085ac9c6268da21faf9bc3f8500a3353cf1e280e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Mon, 26 Feb 2024 23:45:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Ajax.php | 12 +++++------- app/admin/controller/security/SensitiveData.php | 1 + app/admin/library/crud/Helper.php | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/Ajax.php b/app/admin/controller/Ajax.php index 8d9524a8..45bc6b99 100644 --- a/app/admin/controller/Ajax.php +++ b/app/admin/controller/Ajax.php @@ -72,14 +72,12 @@ class Ajax extends Backend if (!$table) { $this->error(__('Parameter error')); } - $tablePk = Db::query("SHOW TABLE STATUS LIKE '$table'", [], true); - if (!$tablePk) { - $table = config('database.connections.mysql.prefix') . $table; - $tablePk = Db::query("SHOW TABLE STATUS LIKE '$table'", [], true); - if (!$tablePk) { - $this->error(__('Data table does not exist')); - } + + $table = TableManager::tableName($table); + if (!TableManager::phinxAdapter(false)->hasTable($table)) { + $this->error(__('Data table does not exist')); } + $tablePk = Db::table($table)->getPk(); $this->success('', ['pk' => $tablePk]); } diff --git a/app/admin/controller/security/SensitiveData.php b/app/admin/controller/security/SensitiveData.php index 9e17eecc..e0f64bbe 100644 --- a/app/admin/controller/security/SensitiveData.php +++ b/app/admin/controller/security/SensitiveData.php @@ -63,6 +63,7 @@ class SensitiveData extends Backend /** * 添加重写 + * @throws Throwable */ public function add(): void { diff --git a/app/admin/library/crud/Helper.php b/app/admin/library/crud/Helper.php index d5243e39..23a5871f 100644 --- a/app/admin/library/crud/Helper.php +++ b/app/admin/library/crud/Helper.php @@ -428,6 +428,7 @@ class Helper * @param array $fields 字段数据 * @param array $designChange 前端字段改变数据 * @return void + * @throws Throwable */ public static function updateFieldOrder(string $tableName, array $fields, array $designChange): void {