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)) {