mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Query类的column方法
This commit is contained in:
@@ -131,8 +131,10 @@ class Query
|
|||||||
$result = Cache::get($guid);
|
$result = Cache::get($guid);
|
||||||
}
|
}
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$key = ($key && '*' != $field) ? $key . ',' : '';
|
if ($key && '*' != $field) {
|
||||||
$pdo = $this->field($key . $field)->fetchPdo(true)->select();
|
$field = $key . ',' . $field;
|
||||||
|
}
|
||||||
|
$pdo = $this->field($field)->fetchPdo(true)->select();
|
||||||
if (1 == $pdo->columnCount()) {
|
if (1 == $pdo->columnCount()) {
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_COLUMN);
|
$result = $pdo->fetchAll(PDO::FETCH_COLUMN);
|
||||||
} else {
|
} else {
|
||||||
@@ -141,11 +143,12 @@ class Query
|
|||||||
$count = count($fields);
|
$count = count($fields);
|
||||||
$key1 = array_shift($fields);
|
$key1 = array_shift($fields);
|
||||||
$key2 = $fields ? array_shift($fields) : '';
|
$key2 = $fields ? array_shift($fields) : '';
|
||||||
|
$key = $key ?: $key1;
|
||||||
foreach ($resultSet as $val) {
|
foreach ($resultSet as $val) {
|
||||||
if ($count > 2) {
|
if ($count > 2) {
|
||||||
$result[$val[$key1]] = $val;
|
$result[$val[$key]] = $val;
|
||||||
} elseif (2 == $count) {
|
} elseif (2 == $count) {
|
||||||
$result[$val[$key1]] = $val[$key2];
|
$result[$val[$key]] = $val[$key2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user