From a8a8d93baa3a07194d2ac39514c2d4e6e73c51a8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 30 Apr 2016 15:05:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=A4=A7=E5=B0=8F=E5=86=99=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E4=BF=AE=E6=AD=A3Query=E7=B1=BB=E7=9A=84w?= =?UTF-8?q?here=E6=96=B9=E6=B3=95=E5=AF=B9=E5=8E=9F=E7=94=9Fsql=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 6 +++++- library/think/db/Query.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index 51919fbb..794198a2 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -49,6 +49,8 @@ abstract class Connection protected $linkID; // 查询结果类型 protected $fetchType = PDO::FETCH_ASSOC; + // 字段属性大小写 + protected $attrCase = PDO::CASE_LOWER; // 监听回调 protected static $event = []; @@ -131,7 +133,7 @@ abstract class Connection protected function fieldCase($info) { // 字段大小写转换 - switch ($this->params[PDO::ATTR_CASE]) { + switch ($this->attrCase) { case PDO::CASE_LOWER: $info = array_change_key_case($info); break; @@ -188,6 +190,8 @@ abstract class Connection } else { $params = $this->params; } + // 记录当前字段属性大小写设置 + $this->attrCase = $params[PDO::ATTR_CASE]; try { if (empty($config['dsn'])) { diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 91d48e86..3606766a 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -491,7 +491,7 @@ class Query if (is_string($field) && !empty($this->options['via'])) { $field = $this->options['via'] . '.' . $field; } - if (is_string($field) && preg_match('/[,=\>\<\'\"\(`.\s]/', $field)) { + if (is_string($field) && preg_match('/[,=\>\<\'\"\(\s]/', $field)) { $where[] = ['exp', $field]; if (is_array($op)) { // 参数绑定