改进数据集对象的返回 由Query类select方法返回数据集对象 Connection类getResult方法不再进行数据集对象转换

This commit is contained in:
thinkphp
2017-01-21 12:36:50 +08:00
parent 7e0282081d
commit 776bf4805e
2 changed files with 3 additions and 6 deletions

View File

@@ -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;
}

View File

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