Skip to content

Commit

Permalink
collection助手函数调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jan 23, 2017
1 parent 390aeb3 commit 86cc937
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
11 changes: 8 additions & 3 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//-------------------------

use think\Cache;
use think\Collection;
use think\Config;
use think\Cookie;
use think\Db;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 86cc937

Please sign in to comment.