withTrashed 用法求解 ,withTrashed 并去掉删除标识为NULL的条件啊?

浏览:1200 发布日期:2016/10/31 分类:求助交流 关键字: 软删除
withTrashed 用法求解 ,withTrashed 并去掉删除标识为NULL的条件啊? 因为base用闭包?
--------------------------------------------
$relation = model('Relation');
$like = $relation->withTrashed()->buildSql();
halt($like);
----------------------------------------------
string(73) "( SELECT * FROM `xin_relation` WHERE `xin_relation`.`deltime` IS NULL )"

##############################

-------------------------
\thinkphp\library\traits\model\SoftDelete.php
-------------------------
/**
* 查询软删除数据
* @access public
* @return \think\db\Query
*/
public static function withTrashed()
{
$model = new static();
return $model->db();
}

protected function base($query)
{
$field = $this->getDeleteTimeField(true);
$query->where($field, 'null');
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>