From 776bf4805eb6bca3681ff221f3095224c2f90c8e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 21 Jan 2017 12:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E7=9A=84=E8=BF=94=E5=9B=9E=20=E7=94=B1Query?= =?UTF-8?q?=E7=B1=BBselect=E6=96=B9=E6=B3=95=E8=BF=94=E5=9B=9E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=AF=B9=E8=B1=A1=20Connection=E7=B1=BBgetRe?= =?UTF-8?q?sult=E6=96=B9=E6=B3=95=E4=B8=8D=E5=86=8D=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=AF=B9=E8=B1=A1=E8=BD=AC=E6=8D=A2?= 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 | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index 4e18f812..9c66ddd1 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -13,7 +13,6 @@ namespace think\db; use PDO; use PDOStatement; -use think\Collection; use think\Db; use think\db\exception\BindParamException; use think\Debug; @@ -547,11 +546,6 @@ abstract class Connection } $result = $this->PDOStatement->fetchAll($this->fetchType); $this->numRows = count($result); - - if ('collection' == $this->resultSetType) { - // 返回数据集Collection对象 - $result = new Collection($result); - } return $result; } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 348535e8..dc05ddaf 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2312,6 +2312,9 @@ class Query } // 模型数据集转换 $resultSet = (new $model)->toCollection($resultSet); + } elseif ('collection' == $this->connection->getConfig('resultset_type')) { + // 返回Collection对象 + $resultSet = new Collection($resultSet); } // 返回结果处理 if (!empty($options['fail']) && count($resultSet) == 0) {