From 134650cee3dd863713b0726f56a52553d81239c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E6=9C=A8?= Date: Fri, 31 May 2019 08:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=8E=92=E5=BA=8F=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=89=80=E4=BD=BF=E7=94=A8=E7=9A=84=E4=B8=BB=E9=94=AE?= =?UTF-8?q?=E5=90=8D=E7=94=B1=E5=9B=BA=E5=AE=9A=E7=9A=84id=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 828e228d2..f48fcdc59 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -152,7 +152,7 @@ class Ajax extends Backend $orderway = $orderway == 'asc' ? 'ASC' : 'DESC'; $sour = $weighdata = []; $ids = explode(',', $ids); - $prikey = 'id'; + $prikey = Db::name($table)->getPk()?:'id'; $pid = $this->request->post("pid"); //限制更新的字段 $field = in_array($field, ['weigh']) ? $field : 'weigh'; @@ -160,9 +160,9 @@ class Ajax extends Backend // 如果设定了pid的值,此时只匹配满足条件的ID,其它忽略 if ($pid !== '') { $hasids = []; - $list = Db::name($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field('id,pid')->select(); + $list = Db::name($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field("$prikey,pid")->select(); foreach ($list as $k => $v) { - $hasids[] = $v['id']; + $hasids[] = $v[$prikey]; } $ids = array_values(array_intersect($ids, $hasids)); } -- Gitee