From 824f33748149878f03efb8da55931d5aa66300cc Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 2 Dec 2021 09:41:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=8D=E5=90=88=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 1de41069..3c5a2359 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -633,17 +633,20 @@ class Crud extends Command $field = 'id'; $order = 'id'; $priDefined = false; - $priKey = ''; + $priKeyArr = []; $relationPrimaryKey = ''; foreach ($columnList as $k => $v) { if ($v['COLUMN_KEY'] == 'PRI') { - $priKey = $v['COLUMN_NAME']; - break; + $priKeyArr[] = $v['COLUMN_NAME']; } } - if (!$priKey) { + if (!$priKeyArr) { throw new Exception('Primary key not found!'); } + if (count($priKeyArr) > 1) { + throw new Exception('Multiple primary key not support!'); + } + $priKey = reset($priKeyArr); $order = $priKey;