PHP Trait traits\model\SoftDelete

Datei anzeigen Open project: top-think/framework

Public Methods

Method Description
delete ( boolean $force = false ) : integer 删除当前的记录
destroy ( mixed $data, boolean $force = false ) : integer 删除记录
onlyTrashed ( ) : Query 只查询软删除数据
restore ( array $where = [] ) : integer 恢复被软删除的记录
trashed ( ) : boolean 判断当前实例是否被软删除
withTrashed ( ) : Query 查询软删除数据

Protected Methods

Method Description
base ( Query $query ) : void 查询默认不包含软删除数据
getDeleteTimeField ( boolean $read = false ) : string 获取软删除字段

Method Details

base() protected method

查询默认不包含软删除数据
protected base ( Query $query ) : void
$query Think\Db\Query 查询对象
return void

delete() public method

删除当前的记录
public delete ( boolean $force = false ) : integer
$force boolean 是否强制删除
return integer

destroy() public static method

删除记录
public static destroy ( mixed $data, boolean $force = false ) : integer
$data mixed 主键列表 支持闭包查询条件
$force boolean 是否强制删除
return integer 成功删除的记录数

getDeleteTimeField() protected method

获取软删除字段
protected getDeleteTimeField ( boolean $read = false ) : string
$read boolean 是否查询操作 写操作的时候会自动去掉表别名
return string

onlyTrashed() public static method

只查询软删除数据
public static onlyTrashed ( ) : Query
return Think\Db\Query

restore() public method

恢复被软删除的记录
public restore ( array $where = [] ) : integer
$where array 更新条件
return integer

trashed() public method

判断当前实例是否被软删除
public trashed ( ) : boolean
return boolean

withTrashed() public static method

查询软删除数据
public static withTrashed ( ) : Query
return Think\Db\Query