From 202bbd7656523e609932de11021e3579143a5199 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 13 Nov 2024 11:33:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=95=B0=E7=BB=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/concern/WhereQuery.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/db/concern/WhereQuery.php b/src/db/concern/WhereQuery.php index 454a427b..5a3a18a3 100644 --- a/src/db/concern/WhereQuery.php +++ b/src/db/concern/WhereQuery.php @@ -48,14 +48,10 @@ public function where($field, $op = null, $condition = null) $param = func_get_args(); array_shift($param); - if (is_array($field) && is_array($field[0])) { - $where = function($query) use($field) { - foreach($field as $item) { - $query->where($item[0], $item[1], $item[2]); - } - }; - $logic = is_string($op) && 'or' == strtolower($op) ? 'OR' : 'AND'; - return $this->parseWhereExp($logic, $where, null, null); + if (is_array($field)) { + return $this->where(function ($query) use ($param, $condition, $op, $field) { + return $query->parseWhereExp('AND', $field, $op, $condition, $param); + }); } return $this->parseWhereExp('AND', $field, $op, $condition, $param); } @@ -100,14 +96,10 @@ public function whereOr($field, $op = null, $condition = null) $param = func_get_args(); array_shift($param); - if (is_array($field) && is_array($field[0])) { - $where = function($query) use($field) { - foreach($field as $item) { - $query->whereOr($item[0], $item[1], $item[2]); - } - }; - $logic = is_string($op) && 'or' == strtolower($op) ? 'OR' : 'AND'; - return $this->parseWhereExp($logic, $where, null, null); + if (is_array($field)) { + return $this->where(function ($query) use ($param, $condition, $op, $field) { + return $query->parseWhereExp('OR', $field, $op, $condition, $param); + }); } return $this->parseWhereExp('OR', $field, $op, $condition, $param);