Query.php
public function column($field, $db = null)
    {
        if ($this->emulateExecution) {
            return [];
        }
        $command = $this->createCommand($db);
        $command->queryParts['_source'] = [$field];
        $result = $command->search();
        if (empty($result['hits']['hits'])) {
            return [];
        }
        $column = [];
        foreach ($result['hits']['hits'] as $row) {
            if (isset($row['fields'][$field])) {
                $column[] = $row['fields'][$field];
            } elseif (isset($row['_source'][$field])) {
                $column[] = $row['_source'][$field];
            } else {
                $column[] = null;
            }
        }
        return $column;
    }
public function column($field, $db = null)
    {
        if ($this->emulateExecution) {
            return [];
        }
        $command = $this->createCommand($db);
        $command->queryParts['_source'] = [$field];
        $result = $command->search();
        if (empty($result['hits']['hits'])) {
            return [];
        }
        $column = [];
        foreach ($result['hits']['hits'] as $row) {
            if (isset($row['fields'][$field])) {
                $column[] = $row['fields'][$field];
            } elseif (isset($row['_source'][$field])) {
                $column[] = $row['_source'][$field];
            } else {
                $column[] = null;
            }
        }
        return $column;
    }
public function column ( $ field , $ db = null ) { if ( $ this -> emulateExecution ) { return [ ] ; } $ command = $ this -> createCommand ( $ db ) ; $ command -> queryParts [ '_source' ] = [ $ field ] ; $ result = $ command -> search ( ) ; if ( empty ( $ result [ 'hits' ] [ 'hits' ] ) ) { return [ ] ; } $ column = [ ] ; foreach ( $ result [ 'hits' ] [ 'hits' ] as $ row ) { if ( isset ( $ row [ 'fields' ] [ $ field ] ) ) { $ column [ ] = $ row [ 'fields' ] [ $ field ] ; } elseif ( isset ( $ row [ '_source' ] [ $ field ] ) ) { $ column [ ] = $ row [ '_source' ] [ $ field ] ; } else { $ column [ ] = null ; } } return $ column ; }
Executes the query and returns the first column of the result.
@param string $field the field to query over
@param Connection $db the database connection used to execute the query.
If this parameter is not given, the `elasticsearch` application component will be used.
@return array the first column of the query result. An empty array is returned if the query results in nothing.
Executes the query and returns the first column of the result .