src/Db/Query.php
public function column($db = null)
    {
        if ($this->emulateExecution) {
            return new LazyPromise(function() { return resolve([]); });
        }

        if ($this->indexBy === null) {
            return $this->createCommand($db)->queryColumn();
        }

        if (is_string($this->indexBy) && is_array($this->select) && count($this->select) === 1) {
            if (strpos($this->indexBy, '.') === false && count($tables = $this->getTablesUsedInFrom()) > 0) {
                $this->select[] = key($tables) . '.' . $this->indexBy;
            } else {
                $this->select[] = $this->indexBy;
            }
        }
        return $this->createCommand($db)->queryAll()->thenLazy(
            function($results) {
                $rows = [];
                foreach ($results as $row) {
                    $value = reset($row);

                    if ($this->indexBy instanceof \Closure) {
                        $rows[call_user_func($this->indexBy, $row)] = $value;
                    } else {
                        $rows[$row[$this->indexBy]] = $value;
                    }
                }

                return $rows;
            }
        );
    }
public function column($db = null)
    {
        if ($this->emulateExecution) {
            return new LazyPromise(function() { return resolve([]); });
        }

        if ($this->indexBy === null) {
            return $this->createCommand($db)->queryColumn();
        }

        if (is_string($this->indexBy) && is_array($this->select) && count($this->select) === 1) {
            if (strpos($this->indexBy, '.') === false && count($tables = $this->getTablesUsedInFrom()) > 0) {
                $this->select[] = key($tables) . '.' . $this->indexBy;
            } else {
                $this->select[] = $this->indexBy;
            }
        }
        return $this->createCommand($db)->queryAll()->thenLazy(
            function($results) {
                $rows = [];
                foreach ($results as $row) {
                    $value = reset($row);

                    if ($this->indexBy instanceof \Closure) {
                        $rows[call_user_func($this->indexBy, $row)] = $value;
                    } else {
                        $rows[$row[$this->indexBy]] = $value;
                    }
                }

                return $rows;
            }
        );
    }
Executes the query and returns the first column of the result.
@param DatabaseInterface|DbConnectionGetterInterface $db the database connection used to generate the SQL statement.
If this parameter is not given, the `db` application component will be used.
@return LazyPromiseInterface with array the first column of the query result. An empty array is returned if the query results in nothing.