Skip to content

Commit 15255d6

Browse files
committed
修正where方法为空的处理
1 parent d878b90 commit 15255d6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/db/concern/WhereQuery.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function where($field, $op = null, $condition = null)
3737
} elseif (true === $field || 1 === $field) {
3838
$this->options['where']['AND'][] = true;
3939

40+
return $this;
41+
} elseif (empty($field)) {
4042
return $this;
4143
}
4244

@@ -96,7 +98,7 @@ public function whereOr($field, $op = null, $condition = null)
9698
$param = func_get_args();
9799
array_shift($param);
98100

99-
if (is_array($field)) {
101+
if (is_array($field) && !empty($field)) {
100102
return $this->where(function ($query) use ($param, $condition, $op, $field) {
101103
return $query->parseWhereExp('OR', $field, $op, $condition, $param);
102104
});
@@ -119,7 +121,7 @@ public function whereXor($field, $op = null, $condition = null)
119121
$param = func_get_args();
120122
array_shift($param);
121123

122-
if (is_array($field)) {
124+
if (is_array($field) && !empty($field)) {
123125
return $this->where(function ($query) use ($param, $condition, $op, $field) {
124126
return $query->parseWhereExp('XOR', $field, $op, $condition, $param);
125127
});

0 commit comments

Comments
 (0)