Skip to content

Commit

Permalink
改进column方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 23, 2019
1 parent 54a66ed commit 37cde31
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/db/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1144,16 +1144,17 @@ public function column(BaseQuery $query, string $column, string $key = ''): arra
} elseif (('*' == $column || strpos($column, ',')) && $key) {
$result = array_column($resultSet, null, $key);
} else {
$fields = array_keys($resultSet[0]);
$key = $key ?: array_shift($fields);
if (empty($key)) {
$key = null;
}

if (strpos($column, ',')) {
$column = null;
} elseif (strpos($column, '.')) {
[$alias, $column] = explode('.', $column);
}

if (strpos($key, '.')) {
if (is_string($key) && strpos($key, '.')) {
[$alias, $key] = explode('.', $key);
}

Expand Down

0 comments on commit 37cde31

Please sign in to comment.