From 86cc9378a0c46e66dabed6681f8b8de758585ae1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 23 Jan 2017 13:59:21 +0800 Subject: [PATCH] =?UTF-8?q?collection=E5=8A=A9=E6=89=8B=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 2 +- helper.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/base.php b/base.php index fdbd5d9098..cbe288bf37 100644 --- a/base.php +++ b/base.php @@ -9,7 +9,7 @@ // | Author: liu21st // +---------------------------------------------------------------------- -define('THINK_VERSION', '5.0.5beta'); +define('THINK_VERSION', '5.0.5'); define('THINK_START_TIME', microtime(true)); define('THINK_START_MEM', memory_get_usage()); define('EXT', '.php'); diff --git a/helper.php b/helper.php index d5946fb275..543942bef1 100644 --- a/helper.php +++ b/helper.php @@ -14,7 +14,6 @@ //------------------------- use think\Cache; -use think\Collection; use think\Config; use think\Cookie; use think\Db; @@ -24,6 +23,7 @@ use think\Lang; use think\Loader; use think\Log; +use think\Model; use think\Request; use think\Response; use think\Session; @@ -571,10 +571,15 @@ function load_relation($resultSet, $relation) /** * 数组转换为数据集对象 * @param array $resultSet 数据集数组 - * @return Collection + * @return \think\model\Collection|\think\Collection */ function collection($resultSet) { - return new Collection($resultSet); + $item = current($resultSet); + if ($item instanceof Model) { + return \think\model\Collection::make($resultSet); + } else { + return \think\Collection::make($resultSet); + } } }