From 9e98ad237f8aa19f2df69786274b85b6ea44d5df Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 29 Jun 2016 17:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84view?= =?UTF-8?q?=E6=96=B9=E6=B3=95field=E5=8F=82=E6=95=B0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8sql=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index b6719410..95213988 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -776,8 +776,13 @@ class Query $fields[] = $alias . '.' . $val; $this->options['map'][$val] = $alias . '.' . $val; } else { - $fields[] = $alias . '.' . $key . ' AS ' . $val; - $this->options['map'][$val] = $alias . '.' . $key; + if (preg_match('/[,=\.\'\"\(\s]/', $key)) { + $name = $key; + } else { + $name = $alias . '.' . $key; + } + $fields[] = $name . ' AS ' . $val; + $this->options['map'][$val] = $name; } } }