$join
$join :
连接查询
菜单模型
$hidden :
newInstance(array|object $data = array(), boolean $isUpdate = false, mixed $where = null) : \think\Model
创建新的模型实例
| array|object | $data | 数据 |
| boolean | $isUpdate | 是否为更新 |
| mixed | $where | 更新条件 |
getQuery(boolean $buildNewQuery = false) : \think\db\Query
获取当前模型的查询对象
| boolean | $buildNewQuery | 创建新的查询对象 |
db(boolean $useBaseQuery = true, boolean $buildNewQuery = true) : \think\db\Query
获取当前模型的数据库查询对象
| boolean | $useBaseQuery | 是否调用全局查询范围 |
| boolean | $buildNewQuery | 创建新的查询对象 |
setParent(\think\Model $model) : $this
设置父关联对象
| \think\Model | $model | 模型对象 |
getParent() : \think\Model
获取父关联对象
toCollection(array|\think\Collection $collection) : \think\Collection
转换当前模型数据集为数据集对象
| array|\think\Collection | $collection | 数据集 |
useGlobalScope(boolean $use) : \think\db\Query
设置是否使用全局查询范围
| boolean | $use | 是否启用全局查询范围 |
has(string $relation, mixed $operator = '>=', integer $count = 1, string $id = '*') : \think\model\Relation|\think\db\Query
根据关联条件查询当前模型
| string | $relation | 关联方法名 |
| mixed | $operator | 比较操作符 |
| integer | $count | 个数 |
| string | $id | 关联表的统计字段 |
hasWhere(string $relation, mixed $where = array(), mixed $fields = null) : \think\model\Relation|\think\db\Query
根据关联条件查询当前模型
| string | $relation | 关联方法名 |
| mixed | $where | 查询条件(数组或者闭包) |
| mixed | $fields | 字段 |
eagerlyResult(\think\Model $result, string $relation) : \think\Model
预载入关联查询 返回模型对象
| \think\Model | $result | 数据对象 |
| string | $relation | 关联名 |
relationCount(\think\Model $result, string|array $relation) : void
关联统计
| \think\Model | $result | 数据对象 |
| string|array | $relation | 关联名 |
hasOne(string $model, string $foreignKey = '', string $localKey = '', array $alias = array(), string $joinType = 'INNER') : \think\model\relation\HasOne
HAS ONE 关联定义
| string | $model | 模型名 |
| string | $foreignKey | 关联外键 |
| string | $localKey | 当前模型主键 |
| array | $alias | 别名定义(已经废弃) |
| string | $joinType | JOIN类型 |
belongsTo(string $model, string $foreignKey = '', string $localKey = '', array $alias = array(), string $joinType = 'INNER') : \think\model\relation\BelongsTo
BELONGS TO 关联定义
| string | $model | 模型名 |
| string | $foreignKey | 关联外键 |
| string | $localKey | 关联主键 |
| array | $alias | 别名定义(已经废弃) |
| string | $joinType | JOIN类型 |
hasMany(string $model, string $foreignKey = '', string $localKey = '') : \think\model\relation\HasMany
HAS MANY 关联定义
| string | $model | 模型名 |
| string | $foreignKey | 关联外键 |
| string | $localKey | 当前模型主键 |
hasManyThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '') : \think\model\relation\HasManyThrough
HAS MANY 远程关联定义
| string | $model | 模型名 |
| string | $through | 中间模型名 |
| string | $foreignKey | 关联外键 |
| string | $throughKey | 关联外键 |
| string | $localKey | 当前模型主键 |
belongsToMany(string $model, string $table = '', string $foreignKey = '', string $localKey = '') : \think\model\relation\BelongsToMany
BELONGS TO MANY 关联定义
| string | $model | 模型名 |
| string | $table | 中间表名 |
| string | $foreignKey | 关联外键 |
| string | $localKey | 当前模型关联键 |
morphMany(string $model, string|array $morph = null, string $type = '') : \think\model\relation\MorphMany
MORPH MANY 关联定义
| string | $model | 模型名 |
| string|array | $morph | 多态字段信息 |
| string | $type | 多态类型 |
morphOne(string $model, string|array $morph = null, string $type = '') : \think\model\relation\MorphOne
MORPH One 关联定义
| string | $model | 模型名 |
| string|array | $morph | 多态字段信息 |
| string | $type | 多态类型 |
morphTo(string|array $morph = null, array $alias = array()) : \think\model\relation\MorphTo
MORPH TO 关联定义
| string|array | $morph | 多态字段信息 |
| array | $alias | 多态别名定义 |
buildQuery() : \think\db\Query
创建模型的查询对象
getRelationData(\think\model\Relation $modelRelation) : mixed
获取关联模型数据
| \think\model\Relation | $modelRelation | 模型关联对象 |
subToArray(\think\Model|\think\model\Collection $model, $visible, $hidden, $key) : array
转换子模型对象
| \think\Model|\think\model\Collection | $model | |
| $visible | ||
| $hidden | ||
| $key |
parseQuery(mixed $data, string $with, boolean $cache) : \think\db\Query
分析查询表达式
| mixed | $data | 主键列表或者查询条件(闭包) |
| string | $with | 关联预查询 |
| boolean | $cache | 是否缓存 |