Relation
public class Relation
Constant Summary | |
---|---|
final static int | |
final static int | |
final static int | |
final static int | |
final static int |
Constructor Summary | |
---|---|
void | __construct(Model model) 架构函数 |
Method Summary | |
---|---|
array|string|integer | getRelationInfo(string name) 获取当前关联信息 |
void | getRelation(mixed name) |
array | eagerlyResultSet(array resultSet, string relation, string class) 预载入关联查询 返回数据集 |
protected mixed | resultSetBuild(array resultSet, string class) 封装关联数据集 |
Model | eagerlyResult(Model result, string relation, string class) 预载入关联查询 返回模型对象 |
protected void | match(string model, string relation, Model result) 一对一 关联模型预查询拼装 |
protected array | eagerlyOneToMany(object model, array where, string relation, string subRelation, bool closure) 一对多 关联模型预查询 |
protected array | eagerlyManyToMany(object model, array where, string relation, string subRelation) 多对多 关联模型预查询 |
$this | setAlias(array alias) 设置当前关联定义的数据表别名 |
$this | hasOne(string model, string foreignKey, string localKey, array alias, string joinType) HAS ONE 关联定义 |
$this | belongsTo(string model, string foreignKey, string otherKey, array alias, string joinType) BELONGS TO 关联定义 |
$this | hasMany(string model, string foreignKey, string localKey, array alias) HAS MANY 关联定义 |
$this | hasManyThrough(string model, string through, string firstkey, string secondKey, string localKey, array alias, mixed foreignKey, mixed throughKey) HAS MANY 远程关联定义 |
$this | belongsToMany(string model, string table, string foreignKey, string localKey, array alias) BELONGS TO MANY 关联定义 |
protected \think\db\Query|string | belongsToManyQuery(object model, string table, string foreignKey, string localKey, array condition) BELONGS TO MANY 关联查询 |
integer | save(mixed data, array pivot) 保存(新增)当前关联数据对象 |
integer | saveAll(array dataSet, array pivot) 批量保存当前关联数据对象 |
integer | attach(mixed data, array pivot) 附加关联的一个中间表数据 |
integer | detach(integer|array data, bool relationDel) 解除关联的一个中间表数据 |
public final static int BELONGS_TO = 3
public final static int BELONGS_TO_MANY = 4
public final static int HAS_MANY = 2
public final static int HAS_MANY_THROUGH = 5
public final static int HAS_ONE = 1
public void __construct(Model model)
架构函数
public array|string|integer getRelationInfo(string name)
获取当前关联信息
public void getRelation(mixed name)
public array eagerlyResultSet(array resultSet, string relation, string class)
预载入关联查询 返回数据集
protected mixed resultSetBuild(array resultSet, string class)
封装关联数据集
public Model eagerlyResult(Model result, string relation, string class)
预载入关联查询 返回模型对象
protected void match(string model, string relation, Model result)
一对一 关联模型预查询拼装
protected array eagerlyOneToMany(object model, array where, string relation, string subRelation, bool closure)
一对多 关联模型预查询
protected array eagerlyManyToMany(object model, array where, string relation, string subRelation)
多对多 关联模型预查询
public $this setAlias(array alias)
设置当前关联定义的数据表别名
public $this hasOne(string model, string foreignKey, string localKey, array alias, string joinType)
HAS ONE 关联定义
public $this belongsTo(string model, string foreignKey, string otherKey, array alias, string joinType)
BELONGS TO 关联定义
public $this hasMany(string model, string foreignKey, string localKey, array alias)
HAS MANY 关联定义
public $this hasManyThrough(string model, string through, string firstkey, string secondKey, string localKey, array alias, mixed foreignKey, mixed throughKey)
HAS MANY 远程关联定义
public $this belongsToMany(string model, string table, string foreignKey, string localKey, array alias)
BELONGS TO MANY 关联定义
protected \think\db\Query|string belongsToManyQuery(object model, string table, string foreignKey, string localKey, array condition)
BELONGS TO MANY 关联查询
public integer save(mixed data, array pivot)
保存(新增)当前关联数据对象
public integer saveAll(array dataSet, array pivot)
批量保存当前关联数据对象
public integer attach(mixed data, array pivot)
附加关联的一个中间表数据
public integer detach(integer|array data, bool relationDel)
解除关联的一个中间表数据