修正软删除的withTrashed方法 Query类增加removeWhereField方法

This commit is contained in:
thinkphp
2016-11-10 11:36:32 +08:00
parent 9b2524d3a1
commit 6f51dd0e47
2 changed files with 18 additions and 1 deletions

View File

@@ -938,6 +938,22 @@ class Query
} }
} }
/**
* 去除某个查询条件
* @access public
* @param string $field 查询字段
* @param string $logic 查询逻辑 and or xor
* @return $this
*/
public function removeWhereField($field, $logic = 'AND')
{
$logic = strtoupper($logic);
if (isset($this->options['where'][$logic][$field])) {
unset($this->options['where'][$logic][$field]);
}
return $this;
}
/** /**
* 指定查询数量 * 指定查询数量
* @access public * @access public

View File

@@ -27,7 +27,8 @@ trait SoftDelete
public static function withTrashed() public static function withTrashed()
{ {
$model = new static(); $model = new static();
return $model->db(false); $field = $model->getDeleteTimeField(true);
return $model->db(false)->removeWhereField($field);
} }
/** /**