From 00fd0b5e203a36af4a5ce1d86f8542046d926b80 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 22 Mar 2017 16:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=BD=AF=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=9C=A8=E4=BD=BF=E7=94=A8=E9=97=AD=E5=8C=85?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=83=85=E5=86=B5=E4=B8=8B=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 414672d1..019b03f8 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -222,6 +222,14 @@ abstract class Builder protected function parseWhere($where, $options) { $whereStr = $this->buildWhere($where, $options); + if (!empty($options['soft_delete'])) { + // 附加软删除条件 + list($field, $condition) = $options['soft_delete']; + + $binds = $this->query->getFieldsBind($options); + $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; + $whereStr = $whereStr . $this->parseWhereItem($field, $condition, '', $options, $binds); + } return empty($whereStr) ? '' : ' WHERE ' . $whereStr; } @@ -280,13 +288,7 @@ abstract class Builder $whereStr .= empty($whereStr) ? substr(implode(' ', $str), strlen($key) + 1) : implode(' ', $str); } - if (!empty($options['soft_delete'])) { - // 附加软删除条件 - list($field, $condition) = $options['soft_delete']; - $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; - $whereStr = $whereStr . $this->parseWhereItem($field, $condition, '', $options, $binds); - } return $whereStr; }