From 28a88d993732f15d3c5f75a075870a14dc04a8c1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 5 May 2016 17:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84column?= =?UTF-8?q?=E5=AF=B9=E6=B2=A1=E6=9C=89=E6=9F=A5=E8=AF=A2=E5=88=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../think/config/driver/ConfigInterface.php | 25 ------------------- library/think/config/driver/Ini.php | 2 +- library/think/config/driver/Xml.php | 2 +- library/think/db/Query.php | 24 ++++++++++-------- 4 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 library/think/config/driver/ConfigInterface.php diff --git a/library/think/config/driver/ConfigInterface.php b/library/think/config/driver/ConfigInterface.php deleted file mode 100644 index c38727c9..00000000 --- a/library/think/config/driver/ConfigInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\config\driver; - -interface ConfigInterface -{ - - /** - * 解析配置 - * @access public - * @param mixed $config 配置 - * @return mixed - */ - public function parse($config); - -} diff --git a/library/think/config/driver/Ini.php b/library/think/config/driver/Ini.php index 61a49df6..d8dc558d 100644 --- a/library/think/config/driver/Ini.php +++ b/library/think/config/driver/Ini.php @@ -11,7 +11,7 @@ namespace think\config\driver; -class Ini implements ConfigInterface +class Ini { public function parse($config) { diff --git a/library/think/config/driver/Xml.php b/library/think/config/driver/Xml.php index 6cbd82bc..5bc93015 100644 --- a/library/think/config/driver/Xml.php +++ b/library/think/config/driver/Xml.php @@ -11,7 +11,7 @@ namespace think\config\driver; -class Xml implements ConfigInterface +class Xml { public function parse($config) { diff --git a/library/think/db/Query.php b/library/think/db/Query.php index c7a5fc78..1483eb5e 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -139,17 +139,21 @@ class Query $result = $pdo->fetchAll(PDO::FETCH_COLUMN); } else { $resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC); - $fields = array_keys($resultSet[0]); - $count = count($fields); - $key1 = array_shift($fields); - $key2 = $fields ? array_shift($fields) : ''; - $key = $key ?: $key1; - foreach ($resultSet as $val) { - if ($count > 2) { - $result[$val[$key]] = $val; - } elseif (2 == $count) { - $result[$val[$key]] = $val[$key2]; + if ($resultSet) { + $fields = array_keys($resultSet[0]); + $count = count($fields); + $key1 = array_shift($fields); + $key2 = $fields ? array_shift($fields) : ''; + $key = $key ?: $key1; + foreach ($resultSet as $val) { + if ($count > 2) { + $result[$val[$key]] = $val; + } elseif (2 == $count) { + $result[$val[$key]] = $val[$key2]; + } } + } else { + $result = []; } } if (isset($cache)) {