mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
改进Query类的column对没有查询到数据的处理
This commit is contained in:
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,17 +139,21 @@ 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);
|
||||||
$fields = array_keys($resultSet[0]);
|
if ($resultSet) {
|
||||||
$count = count($fields);
|
$fields = array_keys($resultSet[0]);
|
||||||
$key1 = array_shift($fields);
|
$count = count($fields);
|
||||||
$key2 = $fields ? array_shift($fields) : '';
|
$key1 = array_shift($fields);
|
||||||
$key = $key ?: $key1;
|
$key2 = $fields ? array_shift($fields) : '';
|
||||||
foreach ($resultSet as $val) {
|
$key = $key ?: $key1;
|
||||||
if ($count > 2) {
|
foreach ($resultSet as $val) {
|
||||||
$result[$val[$key]] = $val;
|
if ($count > 2) {
|
||||||
} elseif (2 == $count) {
|
$result[$val[$key]] = $val;
|
||||||
$result[$val[$key]] = $val[$key2];
|
} elseif (2 == $count) {
|
||||||
|
$result[$val[$key]] = $val[$key2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user