增加collection助手函数 快速转换数组为数据集对象

This commit is contained in:
thinkphp
2017-01-16 23:03:23 +08:00
parent 1568af03d8
commit d68115c946

View File

@@ -23,6 +23,7 @@ use think\exception\HttpResponseException;
use think\Lang;
use think\Loader;
use think\Log;
use think\model\Collection;
use think\Request;
use think\Response;
use think\Session;
@@ -565,3 +566,15 @@ if (!function_exists('load_relation')) {
return $resultSet;
}
}
if (!function_exists('collection')) {
/**
* 数组转换为数据集对象
* @param array $resultSet 数据集数组
* @return Collection
*/
function collection($resultSet)
{
return new Collection($resultSet);
}
}