diff --git a/src/Query/Query.php b/src/Query/Query.php index 16bd506eb..1a2857811 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -24,6 +24,7 @@ use function array_shift; use function array_unshift; use function count; +use function current; use function gettype; use function is_array; use function is_int; @@ -280,7 +281,7 @@ public function column(): array $column = substr($this->indexBy, $dotPos + 1); } - return array_column($rows, key($rows[0]), $column); + return array_column($rows, key(current($rows)), $column); } $rows = $this->createCommand()->queryAll(); @@ -289,7 +290,7 @@ public function column(): array return []; } - return array_combine(array_map($this->indexBy, $rows), array_column($rows, key($rows[0]))); + return array_combine(array_map($this->indexBy, $rows), array_column($rows, key(current($rows)))); } public function count(string $sql = '*'): int|string