From 8fe3e08706636c7967dc9bcd72970c262df404d1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 3 Jul 2016 09:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84value?= =?UTF-8?q?=E5=92=8Ccolumn=E6=96=B9=E6=B3=95=20=E6=94=AF=E6=8C=81=20fetchS?= =?UTF-8?q?ql=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 39943d6b..8b7c5556 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -390,7 +390,11 @@ class Query if (isset($this->options['field'])) { unset($this->options['field']); } - $pdo = $this->field($field)->fetchPdo(true)->find(); + $pdo = $this->field($field)->fetchPdo(true)->find(); + if (is_string($pdo)) { + // 返回SQL语句 + return $pdo; + } $result = $pdo->fetchColumn(); if (isset($cache)) { // 缓存数据 @@ -430,6 +434,10 @@ class Query $field = $key . ',' . $field; } $pdo = $this->field($field)->fetchPdo(true)->select(); + if (is_string($pdo)) { + // 返回SQL语句 + return $pdo; + } if (1 == $pdo->columnCount()) { $result = $pdo->fetchAll(PDO::FETCH_COLUMN); } else {