$parent
$parent : \think\Model
父模型对象
多态关联类
$parent : \think\Model
父模型对象
getParent() : \think\Model
获取关联的所属模型
getModel() : \think\Model
获取当前的关联模型类的实例
__construct(\think\Model $parent, string $morphType, string $morphKey, array $alias = array(), string $relation = null)
架构函数
\think\Model | $parent | 上级模型对象 |
string | $morphType | 多态字段名 |
string | $morphKey | 外键名 |
array | $alias | 多态别名定义 |
string | $relation | 关联名 |
getRelation(array $subRelation = array(), \Closure $closure = null) : \think\Model
延迟获取关联数据
array | $subRelation | 子关联名 |
\Closure | $closure | 闭包查询条件 |
has(string $operator = '>=', integer $count = 1, string $id = '*', string $joinType = '', \think\model\relation\Query $query = null) : \think\model\relation\Query
根据关联条件查询当前模型
string | $operator | 比较操作符 |
integer | $count | 个数 |
string | $id | 关联表的统计字段 |
string | $joinType | JOIN类型 |
\think\model\relation\Query | $query | Query对象 |
hasWhere(mixed $where = array(), mixed $fields = null, string $joinType = '', \think\model\relation\Query $query = null) : \think\model\relation\Query
根据关联条件查询当前模型
mixed | $where | 查询条件(数组或者闭包) |
mixed | $fields | 字段 |
string | $joinType | JOIN类型 |
\think\model\relation\Query | $query | Query对象 |
eagerlyResultSet(array $resultSet, string $relation, array $subRelation, \Closure $closure = null, array $cache = array()) : void
预载入关联查询
array | $resultSet | 数据集 |
string | $relation | 当前关联名 |
array | $subRelation | 子关联名 |
\Closure | $closure | 闭包 |
array | $cache | 关联缓存 |
eagerlyResult(\think\Model $result, string $relation, array $subRelation = array(), \Closure $closure = null, array $cache = array()) : void
预载入关联查询
\think\Model | $result | 数据对象 |
string | $relation | 当前关联名 |
array | $subRelation | 子关联名 |
\Closure | $closure | 闭包 |
array | $cache | 关联缓存 |
relationCount(\think\Model $result, \Closure $closure = null, string $aggregate = 'count', string $field = '*') : integer
关联统计
\think\Model | $result | 数据对象 |
\Closure | $closure | 闭包 |
string | $aggregate | 聚合查询方法 |
string | $field | 字段 |
associate(\think\Model $model, string $type = '') : \think\Model
添加关联数据
\think\Model | $model | 关联模型对象 |
string | $type | 多态类型 |
dissociate() : \think\Model
注销关联数据
resultSetBuild(array $resultSet, \think\Model $parent = null) : mixed
封装关联数据集
array | $resultSet | 数据集 |
\think\Model | $parent | 父模型 |
eagerlyMorphToOne(string $model, string $relation, \think\Model $result, array $subRelation = array(), array $cache = array()) : void
多态MorphTo 关联模型预查询
string | $model | 关联模型对象 |
string | $relation | 关联名 |
\think\Model | $result | |
array | $subRelation | 子关联 |
array | $cache | 关联缓存 |