mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-03 05:52:48 +08:00
Model类增加resultSetType属性 用于指定模型查询的数据集对象(默认为空返回数组) Db类查询不再支持设置自定义数据集对象(只能使用数组或者think\Collection)
This commit is contained in:
@@ -111,6 +111,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
protected $useGlobalScope = true;
|
||||
// 是否采用批量验证
|
||||
protected $batchValidate = false;
|
||||
// 查询数据集对象
|
||||
protected $resultSetType;
|
||||
|
||||
/**
|
||||
* 初始化过的模型.
|
||||
@@ -574,7 +576,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
*/
|
||||
public function toCollection($collection)
|
||||
{
|
||||
return new Collection($collection);
|
||||
if ($this->resultSetType) {
|
||||
if ('collection' == $this->resultSetType) {
|
||||
$collection = new Collection($collection);
|
||||
} else {
|
||||
$class = $this->resultSetType;
|
||||
$collection = new $class($collection);
|
||||
}
|
||||
}
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user