From 464c945efb18c352c7f656f0b7fed7c8a1e45b5b Mon Sep 17 00:00:00 2001 From: hnh0000 Date: Thu, 30 Apr 2020 13:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Backend.php | 27 ++++++++--------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 1945fd82b..c1f651973 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -54,7 +54,7 @@ class Backend extends Controller protected $searchFields = 'id'; /** - * 是否是关联查询 + * 已废弃(保留,为了兼容之前写的控制器),是否是关联查询 */ protected $relationSearch = false; @@ -245,13 +245,11 @@ class Backend extends Controller /** * 生成查询所需要的条件,排序方式 * @param mixed $searchfields 快速查询的字段 - * @param boolean $relationSearch 是否关联查询 * @return array */ - protected function buildparams($searchfields = null, $relationSearch = null) + protected function buildparams($searchfields = null) { $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields; - $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch; $search = $this->request->get("search", ''); $filter = $this->request->get("filter", ''); $op = $this->request->get("op", '', 'trim'); @@ -263,20 +261,13 @@ class Backend extends Controller $op = (array)json_decode($op, true); $filter = $filter ? $filter : []; $where = []; - $tableName = ''; - if ($relationSearch) { - if (!empty($this->model)) { - $name = \think\Loader::parseName(basename(str_replace('\\', '/', get_class($this->model)))); - $name = $this->model->getTable(); - $tableName = $name . '.'; - } - $sortArr = explode(',', $sort); - foreach ($sortArr as $index => & $item) { - $item = stripos($item, ".") === false ? $tableName . trim($item) : $item; - } - unset($item); - $sort = implode(',', $sortArr); + $tableName = '__TABLE__.'; + $sortArr = explode(',', $sort); + foreach ($sortArr as $index => & $item) { + $item = stripos($item, ".") === false ? $tableName . trim($item) : $item; } + unset($item); + $sort = implode(',', $sortArr); $adminIds = $this->getDataLimitAdminIds(); if (is_array($adminIds)) { $where[] = [$tableName . $this->dataLimitField, 'in', $adminIds]; @@ -316,7 +307,7 @@ class Backend extends Controller case 'FINDIN': case 'FINDINSET': case 'FIND_IN_SET': - $where[] = "FIND_IN_SET('{$v}', " . ($relationSearch ? $k : '`' . str_replace('.', '`.`', $k) . '`') . ")"; + $where[] = "FIND_IN_SET('{$v}', " . $k . ")"; break; case 'IN': case 'IN(...)': -- Gitee