改进Query类的column对没有查询到数据的处理

This commit is contained in:
thinkphp
2016-05-05 17:30:29 +08:00
parent b6072ebe48
commit 28a88d9937
4 changed files with 16 additions and 37 deletions

View File

@@ -1,25 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\config\driver;
interface ConfigInterface
{
/**
* 解析配置
* @access public
* @param mixed $config 配置
* @return mixed
*/
public function parse($config);
}

View File

@@ -11,7 +11,7 @@
namespace think\config\driver; namespace think\config\driver;
class Ini implements ConfigInterface class Ini
{ {
public function parse($config) public function parse($config)
{ {

View File

@@ -11,7 +11,7 @@
namespace think\config\driver; namespace think\config\driver;
class Xml implements ConfigInterface class Xml
{ {
public function parse($config) public function parse($config)
{ {

View File

@@ -139,6 +139,7 @@ class Query
$result = $pdo->fetchAll(PDO::FETCH_COLUMN); $result = $pdo->fetchAll(PDO::FETCH_COLUMN);
} else { } else {
$resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC); $resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC);
if ($resultSet) {
$fields = array_keys($resultSet[0]); $fields = array_keys($resultSet[0]);
$count = count($fields); $count = count($fields);
$key1 = array_shift($fields); $key1 = array_shift($fields);
@@ -151,6 +152,9 @@ class Query
$result[$val[$key]] = $val[$key2]; $result[$val[$key]] = $val[$key2];
} }
} }
} else {
$result = [];
}
} }
if (isset($cache)) { if (isset($cache)) {
// 缓存数据 // 缓存数据