$relationWrite
$relationWrite : array
关联自动写入信息
模型关联处理
$relationWrite : array
关联自动写入信息
$parent : object
父关联模型对象
$relation : array
模型关联数据
$together : array
关联写入定义信息
has(string $relation, mixed $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', \think\db\BaseQuery $query = null) : \think\db\BaseQuery
根据关联条件查询当前模型
string | $relation | 关联方法名 |
mixed | $operator | 比较操作符 |
int | $count | 个数 |
string | $id | 关联表的统计字段 |
string | $joinType | JOIN类型 |
\think\db\BaseQuery | $query | Query对象 |
hasWhere(string $relation, mixed $where = [], mixed $fields = '*', string $joinType = '', \think\db\BaseQuery $query = null) : \think\db\BaseQuery
根据关联条件查询当前模型
string | $relation | 关联方法名 |
mixed | $where | 查询条件(数组或者闭包) |
mixed | $fields | 字段 |
string | $joinType | JOIN类型 |
\think\db\BaseQuery | $query | Query对象 |
eagerly(\think\db\BaseQuery $query, string $relation, mixed $field, string $joinType = '', \Closure $closure = null, bool $first = false) : bool
预载入关联查询 JOIN方式
\think\db\BaseQuery | $query | Query对象 |
string | $relation | 关联方法名 |
mixed | $field | 字段 |
string | $joinType | JOIN类型 |
\Closure | $closure | 闭包 |
bool | $first |
hasManyThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = '') : \think\model\relation\HasManyThrough
HAS MANY 远程关联定义
string | $model | 模型名 |
string | $through | 中间模型名 |
string | $foreignKey | 关联外键 |
string | $throughKey | 关联外键 |
string | $localKey | 当前主键 |
string | $throughPk | 中间表主键 |
hasOneThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = '') : \think\model\relation\HasOneThrough
HAS ONE 远程关联定义
string | $model | 模型名 |
string | $through | 中间模型名 |
string | $foreignKey | 关联外键 |
string | $throughKey | 关联外键 |
string | $localKey | 当前主键 |
string | $throughPk | 中间表主键 |
belongsToMany(string $model, string $middle = '', string $foreignKey = '', string $localKey = '') : \think\model\relation\BelongsToMany
BELONGS TO MANY 关联定义
string | $model | 模型名 |
string | $middle | 中间表/模型名 |
string | $foreignKey | 关联外键 |
string | $localKey | 当前模型关联键 |
morphToMany(string $model, string $middle, string|array $morph = null, string $localKey = null) : \think\model\relation\MorphToMany
MORPH TO MANY关联定义
string | $model | 模型名 |
string | $middle | 中间表名/模型名 |
string|array | $morph | 多态字段信息 |
string | $localKey | 当前模型关联键 |
morphByMany(string $model, string $middle, string|array $morph = null, string $foreignKey = null) : \think\model\relation\MorphToMany
MORPH BY MANY关联定义
string | $model | 模型名 |
string | $middle | 中间表名/模型名 |
string|array | $morph | 多态字段信息 |
string | $foreignKey | 关联外键 |