From fb66950ded99a8aa3b13dc8002a58ba3f91dd28e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 6 Aug 2016 11:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0onlyTrashed=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/traits/model/SoftDelete.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/traits/model/SoftDelete.php b/library/traits/model/SoftDelete.php index ee120ae5..854a55fe 100644 --- a/library/traits/model/SoftDelete.php +++ b/library/traits/model/SoftDelete.php @@ -44,6 +44,17 @@ trait SoftDelete return $model->db(); } + /** + * 只查询软删除数据 + * @access public + * @return \think\db\Query + */ + public static function onlyTrashed() + { + $model = new static(); + return $model->db()->where(static::$deleteTime, '>', 0); + } + /** * 删除当前的记录 * @access public