From 32ba255de9f559324555da4e8c04af32a1c07a8c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 10 Apr 2016 23:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bwhere=E5=AF=B9=E7=A9=BA?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Driver.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/library/think/db/Driver.php b/library/think/db/Driver.php index 039b39b2..bf8b50e5 100644 --- a/library/think/db/Driver.php +++ b/library/think/db/Driver.php @@ -665,11 +665,12 @@ abstract class Driver } $where = $this->parseWhereExp($field, $op, $condition); - - if (!isset($this->options['where']['AND'])) { - $this->options['where']['AND'] = []; + if (!empty($where)) { + if (!isset($this->options['where']['AND'])) { + $this->options['where']['AND'] = []; + } + $this->options['where']['AND'] = array_merge($this->options['where']['AND'], $where); } - $this->options['where']['AND'] = array_merge($this->options['where']['AND'], $where); return $this; } @@ -684,10 +685,12 @@ abstract class Driver public function whereOr($field, $op = null, $condition = null) { $where = $this->parseWhereExp($field, $op, $condition); - if (!isset($this->options['where']['OR'])) { - $this->options['where']['OR'] = []; + if (!empty($where)) { + if (!isset($this->options['where']['OR'])) { + $this->options['where']['OR'] = []; + } + $this->options['where']['OR'] = array_merge($this->options['where']['OR'], $where); } - $this->options['where']['OR'] = array_merge($this->options['where']['OR'], $where); return $this; }