src/Query.php
public function field($field, $alias = null)
    {
        // field is passed as string, may contain commas
        if (is_string($field) && strpos($field, ',') !== false) {
            $field = explode(',', $field);
        }

        // recursively add array fields
        if (is_array($field)) {
            if ($alias !== null) {
                throw new Exception([
                    'Alias must not be specified when $field is an array',
                    'alias' => $alias,
                ]);
            }

            foreach ($field as $alias => $f) {
                if (is_numeric($alias)) {
                    $alias = null;
                }
                $this->field($f, $alias);
            }

            return $this;
        }

        // save field in args
        $this->_set_args('field', $alias, $field);

        return $this;
    }
public function field($field, $alias = null)
    {
        // field is passed as string, may contain commas
        if (is_string($field) && strpos($field, ',') !== false) {
            $field = explode(',', $field);
        }

        // recursively add array fields
        if (is_array($field)) {
            if ($alias !== null) {
                throw new Exception([
                    'Alias must not be specified when $field is an array',
                    'alias' => $alias,
                ]);
            }

            foreach ($field as $alias => $f) {
                if (is_numeric($alias)) {
                    $alias = null;
                }
                $this->field($f, $alias);
            }

            return $this;
        }

        // save field in args
        $this->_set_args('field', $alias, $field);

        return $this;
    }
Adds new column to resulting select by querying $field.

Examples:
$q->field('name');

You can use a dot to prepend table name to the field:
$q->field('user.name');
$q->field('user.name')->field('address.line1');

Array as a first argument will specify multiple fields, same as calling field() multiple times
$q->field(['name', 'surname', 'address.line1']);

You can pass first argument as Expression or Query
$q->field( $q->expr('2+2'), 'alias');   // must always use alias

You can use $q->dsql() for subqueries. Subqueries will be wrapped in
brackets.
$q->field( $q->dsql()->table('x')... , 'alias');

Associative array will assume that "key" holds the field alias.
Value may be field name, Expression or Query.
$q->field(['alias' => 'name', 'alias2' => 'mother.surname']);
$q->field(['alias' => $q->expr(..), 'alias2' => $q->dsql()->.. ]);

If you need to use funky name for the field (e.g, one containing
a dot or a space), you should wrap it into expression:
$q->field($q->expr('{}', ['fun...ky.field']), 'f');

@param mixed  $field Specifies field to select
@param string $alias Specify alias for this field

@return $this