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