diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 99ae42a4..3f4d5fd0 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -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 diff --git a/library/traits/model/SoftDelete.php b/library/traits/model/SoftDelete.php index 9f7cedce..8ecf35de 100644 --- a/library/traits/model/SoftDelete.php +++ b/library/traits/model/SoftDelete.php @@ -27,7 +27,8 @@ trait SoftDelete public static function withTrashed() { $model = new static(); - return $model->db(false); + $field = $model->getDeleteTimeField(true); + return $model->db(false)->removeWhereField($field); } /**