atk4\data\Reference_SQL_One::addFields PHP Method

addFields() public method

[ 'name', 'surname' ] - will import those fields as-is [ 'full_name' => 'name', 'day_of_birth' => ['dob', 'type'=>'date'] ] - use alias and options [ ['dob', 'type' => 'date'] ] - use options You may also use second param to specify parameters: addFields(['from', 'to'], ['type' => 'date']);
public addFields ( array $fields = [], $defaults = [] )
$fields array
    public function addFields($fields = [], $defaults = [])
    {
        foreach ($fields as $field => $alias) {
            if (is_array($alias)) {
                $d = array_merge($defaults, $alias);
                if (!isset($alias[0])) {
                    throw Exception('Incorrect definition for addFields. Field name must be specified', ['field' => $field, 'alias' => $alias]);
                }
                $alias = $alias[0];
            } else {
                $d = $defaults;
            }
            if (is_numeric($field)) {
                $field = $alias;
            }
            $d[0] = $field;
            $this->addField($d, $alias);
        }
        return $this;
    }