From 4d1b4583f89f01446d1a87066d3e5ce496c0b701 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 12 Nov 2024 21:56:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/db/concern/WhereQuery.php b/src/db/concern/WhereQuery.php index 19d044df..454a427b 100644 --- a/src/db/concern/WhereQuery.php +++ b/src/db/concern/WhereQuery.php @@ -48,6 +48,15 @@ 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); + } return $this->parseWhereExp('AND', $field, $op, $condition, $param); } @@ -91,6 +100,16 @@ 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); + } + return $this->parseWhereExp('OR', $field, $op, $condition, $param); }