diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 828e228d2d8eb97229e1ec4cf9af2fe713935747..f48fcdc59b6dbc6161193fafd09bce1bc8ef668e 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)); }