From 015655c64ea2fa146f3a457670e90824837e1da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=87=82=E4=B8=8D=E8=83=BD=E6=87=82?= <295047320@qq.com> Date: Fri, 16 May 2025 03:34:50 +0000 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4where=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 懂不能懂 <295047320@qq.com> --- app/common/controller/Backend.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/common/controller/Backend.php b/app/common/controller/Backend.php index 8e1a266f..525c2bbb 100644 --- a/app/common/controller/Backend.php +++ b/app/common/controller/Backend.php @@ -53,6 +53,12 @@ class Backend extends Api */ protected string|array $defaultSortField = []; + /** + * 默认where条件 + * @var array ['id','=', 1] + */ + protected array $defaultWhere = []; + /** * 有序保证 * 查询数据时总是需要指定 ORDER BY 子句,否则 MySQL 不保证排序,即先查到哪行就输出哪行且不保证多次查询中的输出顺序 @@ -186,7 +192,7 @@ class Backend extends Api $initValue = $this->request->get("initValue", ''); $initOperator = $this->request->get("initOperator/s", 'in'); - $where = []; + $where = $this->defaultWhere; $modelTable = strtolower($this->model->getTable()); $alias[$modelTable] = parse_name(basename(str_replace('\\', '/', get_class($this->model)))); $mainTableAlias = $alias[$modelTable] . '.'; -- Gitee