PHP Class think\model\Merge

Inheritance: extends think\Model
Show file Open project: top-think/framework

Protected Properties

Property Type Description
$fk HAS ONE 关联的模型列表
$mapFields 外键名 默认为主表名_id
$relationModel

Public Methods

Method Description
__construct ( array | object $data = [] ) 架构函数
all ( mixed $data = null, string $with = [], $cache = false ) : array | false | string 查找所有记录
delete ( ) : integer 删除当前的记录 并删除关联数据
get ( mixed $data = null, string $with = [], boolean $cache = false ) : Model 查找单条记录
save ( mixed $data = [], array $where = [], string $sequence = null ) : integer | false 保存模型数据 以及关联数据

Protected Methods

Method Description
attachQuery ( Query $query ) : Query 附加查询表达式
getModelField ( Query $query, string $name, string $table = '', array $map = [] ) : array 获取关联模型的字段 并解决混淆
parseData ( string $model, array $data, boolean $insert = false ) : void 处理写入的模型数据

Method Details

__construct() public method

架构函数
public __construct ( array | object $data = [] )
$data array | object 数据

all() public static method

查找所有记录
public static all ( mixed $data = null, string $with = [], $cache = false ) : array | false | string
$data mixed 主键列表或者查询条件(闭包)
$with string 关联预查询
return array | false | string

attachQuery() protected static method

附加查询表达式
protected static attachQuery ( Query $query ) : Query
$query Think\Db\Query 查询对象
return Think\Db\Query

delete() public method

删除当前的记录 并删除关联数据
public delete ( ) : integer
return integer

get() public static method

查找单条记录
public static get ( mixed $data = null, string $with = [], boolean $cache = false ) : Model
$data mixed 主键值或者查询条件(闭包)
$with string 关联预查询
$cache boolean 是否缓存
return think\Model

getModelField() protected static method

获取关联模型的字段 并解决混淆
protected static getModelField ( Query $query, string $name, string $table = '', array $map = [] ) : array
$query Think\Db\Query 查询对象
$name string 模型名称
$table string 关联表名称
$map array 字段映射
return array

parseData() protected method

处理写入的模型数据
protected parseData ( string $model, array $data, boolean $insert = false ) : void
$model string 模型名称
$data array 数据
$insert boolean 是否新增
return void

save() public method

保存模型数据 以及关联数据
public save ( mixed $data = [], array $where = [], string $sequence = null ) : integer | false
$data mixed 数据
$where array 更新条件
$sequence string 自增序列名
return integer | false

Property Details

$fk protected property

HAS ONE 关联的模型列表
protected $fk

$mapFields protected property

外键名 默认为主表名_id
protected $mapFields

$relationModel protected property

protected $relationModel