From f00825a477e47cd2bc59bad09fa84845ce089267 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 18 Feb 2017 21:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/builder/Mysql.php | 5 +++-- library/think/db/builder/Pgsql.php | 5 +++-- library/think/db/builder/Sqlite.php | 5 +++-- library/think/db/builder/Sqlsrv.php | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/library/think/db/builder/Mysql.php b/library/think/db/builder/Mysql.php index e432e396..4aac4424 100644 --- a/library/think/db/builder/Mysql.php +++ b/library/think/db/builder/Mysql.php @@ -36,10 +36,11 @@ class Mysql extends Builder $key = 'json_extract(' . $field . ', \'$.' . $name . '\')'; } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } if (isset($options['alias'][$table])) { $table = $options['alias'][$table]; - } elseif ('__TABLE__' == $table) { - $table = $this->query->getTable(); } } if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { diff --git a/library/think/db/builder/Pgsql.php b/library/think/db/builder/Pgsql.php index 67b98b44..5be0468a 100644 --- a/library/think/db/builder/Pgsql.php +++ b/library/think/db/builder/Pgsql.php @@ -55,10 +55,11 @@ class Pgsql extends Builder $key = $field . '->>\'' . $name . '\''; } elseif (strpos($key, '.')) { list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } if (isset($options['alias'][$table])) { $table = $options['alias'][$table]; - } elseif ('__TABLE__' == $table) { - $table = $this->query->getTable(); } } if (isset($table)) { diff --git a/library/think/db/builder/Sqlite.php b/library/think/db/builder/Sqlite.php index 680b4965..55d3abc4 100644 --- a/library/think/db/builder/Sqlite.php +++ b/library/think/db/builder/Sqlite.php @@ -60,10 +60,11 @@ class Sqlite extends Builder $key = trim($key); if (strpos($key, '.')) { list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } if (isset($options['alias'][$table])) { $table = $options['alias'][$table]; - } elseif ('__TABLE__' == $table) { - $table = $this->query->getTable(); } } if (isset($table)) { diff --git a/library/think/db/builder/Sqlsrv.php b/library/think/db/builder/Sqlsrv.php index 99f68409..2e13d3fb 100644 --- a/library/think/db/builder/Sqlsrv.php +++ b/library/think/db/builder/Sqlsrv.php @@ -73,10 +73,11 @@ class Sqlsrv extends Builder $key = trim($key); if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { list($table, $key) = explode('.', $key, 2); + if ('__TABLE__' == $table) { + $table = $this->query->getTable(); + } if (isset($options['alias'][$table])) { $table = $options['alias'][$table]; - } elseif ('__TABLE__' == $table) { - $table = $this->query->getTable(); } } if (!is_numeric($key) && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) {