ThinkPHP5


think\model\Merge
library\think\model\Merge.php at line 17

Class Merge

Model
└─Merge

public class Merge
extends Model

Class Model

Method:
static PaginatorCollection paginate(integer $listRows = 15, boolean $simple = false, array $config = []) 分页查询
static mixed value($field, $default = null) 得到某个字段的值
static array column($field, $key = '') 得到某个列的数组
static integer count($field = '*') COUNT查询
static integer sum($field = '*') SUM查询
static integer min($field = '*') MIN查询
static integer max($field = '*') MAX查询
static integer avg($field = '*') AVG查询
static setField($field, $value = '')
static Query where($field, $op = null, $condition = null) 指定AND查询条件
static static findOrFail($data = null) 查找单条记录 如果不存在则抛出异常

Constructor Summary
void

__construct(array|object data)

架构函数

Method Summary
static \think\Model

get(mixed data, string with, bool cache)

查找单条记录

protected static \think\db\Query

attachQuery(\think\db\Query query)

附加查询表达式

protected static array

getModelField(\think\db\Query query, string name, string table, array map)

获取关联模型的字段 并解决混淆

static array|false|string

all(mixed data, string with, bool cache)

查找所有记录

protected void

parseData(string model, array data, bool insert)

处理写入的模型数据

integer|false

save(array data, array where, string sequence)

保存模型数据 以及关联数据

integer

delete()

删除当前的记录 并删除关联数据

Methods inherited from think\Model
__construct, all, allowField, append, auto, autoCompleteData, autoWriteTimestamp, belongsTo, belongsToMany, create, data, db, delete, destroy, eagerlyResult, eagerlyResultSet, event, get, getAttr, getData, getDb, getError, getPk, has, hasMany, hasManyThrough, hasOne, hasWhere, hidden, init, initialize, isPk, isUpdate, jsonSerialize, offsetExists, offsetGet, offsetSet, offsetUnset, parseModel, parseQuery, readTransform, relation, relationQuery, save, saveAll, scope, setAttr, toArray, toJson, trigger, update, useGlobalScope, validate, validateData, validateFailException, visible, writeTransform

Constructor Detail

library\think\model\Merge.php at line 29

__construct

public void __construct(array|object data)

架构函数

Parameters:
data - 数据

Method Detail

library\think\model\Merge.php at line 47

get

public static \think\Model get(mixed data, string with, bool cache)

查找单条记录

Parameters:
data - 主键值或者查询条件(闭包)
with - 关联预查询
cache - 是否缓存
Throws:
exception\DbException

library\think\model\Merge.php at line 60

attachQuery

protected static \think\db\Query attachQuery(\think\db\Query query)

附加查询表达式

Parameters:
query - 查询对象

library\think\model\Merge.php at line 86

getModelField

protected static array getModelField(\think\db\Query query, string name, string table, array map)

获取关联模型的字段 并解决混淆

Parameters:
query - 查询对象
name - 模型名称
table - 关联表名称
map - 字段映射

library\think\model\Merge.php at line 109

all

public static array|false|string all(mixed data, string with, bool cache)

查找所有记录

Parameters:
data - 主键列表或者查询条件(闭包)
with - 关联预查询
Throws:
exception\DbException

library\think\model\Merge.php at line 124

parseData

protected void parseData(string model, array data, bool insert)

处理写入的模型数据

Parameters:
model - 模型名称
data - 数据
insert - 是否新增

library\think\model\Merge.php at line 150

save

public integer|false save(array data, array where, string sequence)

保存模型数据 以及关联数据

Parameters:
data - 数据
where - 更新条件
sequence - 自增序列名

library\think\model\Merge.php at line 285

delete

public integer delete()

删除当前的记录 并删除关联数据


ThinkPHP5