From e3339ad15855a492b9bff501925baaaa7484fe28 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 3 Aug 2016 17:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bsqlsrv=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/connector/Sqlsrv.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/think/db/connector/Sqlsrv.php b/library/think/db/connector/Sqlsrv.php index 31cf9045..cce0c6c8 100644 --- a/library/think/db/connector/Sqlsrv.php +++ b/library/think/db/connector/Sqlsrv.php @@ -74,6 +74,12 @@ class Sqlsrv extends Connection ]; } } + $sql = "SELECT column_name FROM information_schema.key_column_usage WHERE table_name='$tableName'"; + $pdo = $this->linkID->query($sql); + $result = $pdo->fetch(PDO::FETCH_ASSOC); + if ($result) { + $info[$result['column_name']]['primary'] = true; + } return $this->fieldCase($info); }