collection助手函数调整

This commit is contained in:
thinkphp
2017-01-23 13:59:21 +08:00
parent 390aeb3f01
commit 86cc9378a0
2 changed files with 9 additions and 4 deletions

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
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');

View File

@@ -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\exception\HttpResponseException;
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 @@ if (!function_exists('collection')) {
/**
* 数组转换为数据集对象
* @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);
}
}
}