From cd787eef118d175379b6d4cff20ccf21f190441b Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 27 Aug 2025 16:13:48 +0800 Subject: [PATCH] * [refac] Refactor: simplify tableExists method by removing switch statement. --- lib/dbh/dbh.class.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index db48f0fac6..e539fe902d 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -391,20 +391,14 @@ class dbh public function tableExits($tableName) { $tableName = str_replace(array("'", '`'), "", $tableName); - $sql = "SHOW TABLES FROM {$this->dbConfig->name} like '{$tableName}'"; - switch($this->dbConfig->driver) + + if($this->dbConfig->driver == 'dm') { - case 'oceanbase': - case 'mysql': - $sql = "SHOW TABLES FROM {$this->dbConfig->name} like '{$tableName}'"; - break; - case 'dm': - $sql = "SELECT * FROM all_tables WHERE owner='{$this->dbConfig->name}' AND table_name='{$tableName}'"; - break; - default: - $sql = ''; + $sql = "SELECT * FROM all_tables WHERE owner='{$this->dbConfig->name}' AND table_name='{$tableName}'"; + return $this->rawQuery($sql)->fetch(); } + $sql = "SHOW TABLES FROM {$this->dbConfig->name} like '{$tableName}'"; return $this->rawQuery($sql)->fetch(); }