From 7fa018ca0c5714fe0f2a11279824f3ae927f95a8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 3 Jan 2017 14:37:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BMysql=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E7=9A=84getFields=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/connector/Mysql.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/think/db/connector/Mysql.php b/library/think/db/connector/Mysql.php index fd6f4ece..31435694 100644 --- a/library/think/db/connector/Mysql.php +++ b/library/think/db/connector/Mysql.php @@ -51,10 +51,13 @@ class Mysql extends Connection { $this->initConnect(true); list($tableName) = explode(' ', $tableName); - if (strpos($tableName, '.')) { - $tableName = str_replace('.', '`.`', $tableName); + if (false === strpos($tableName, '`')) { + if (strpos($tableName, '.')) { + $tableName = str_replace('.', '`.`', $tableName); + } + $tableName = '`' . $tableName . '`'; } - $sql = 'SHOW COLUMNS FROM `' . $tableName . '`'; + $sql = 'SHOW COLUMNS FROM ' . $tableName; // 调试开始 $this->debug(true); $pdo = $this->linkID->query($sql);