Skip to content

Commit

Permalink
完善Query的column方法以支持指定表别名
Browse files Browse the repository at this point in the history
  • Loading branch information
Eno-CN authored Oct 31, 2024
1 parent 14e4be7 commit 41b8c2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Db/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,13 @@ public function column($fields, ?string $key = null): array
$records = $result->getStatementRecords();
if (1 === \count($rawFields))
{
return array_column($records, $rawFields[0], $key);
$column = $rawFields[0];
if (strpos($column, '.'))
{
[, $column] = explode('.', $column);
}

return array_column($records, $column, $key);
}
else
{
Expand Down

0 comments on commit 41b8c2e

Please sign in to comment.