public function fields($fields)
    {
        // we always have to reset the fields
        $this->fields = array();

        // when a string is given
        if (is_string($fields)) 
        {
            $fields = $this->stringArgumentToArray($fields);
        }
        // it also could be an object
        elseif (is_object($fields))
        {
            return $this->addField($fields);
        }

        // do nothing if we get nothing
        if (empty($fields) || $fields === array('*') || $fields === array('')) { return $this; }

        // add the fields
        foreach($fields as $key => $field)
        {
            // when we have a string as key we have an alias definition
            if (is_string($key))
            {
                $this->addField($key, $field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
public function fields($fields)
    {
        // we always have to reset the fields
        $this->fields = array();

        // when a string is given
        if (is_string($fields)) 
        {
            $fields = $this->stringArgumentToArray($fields);
        }
        // it also could be an object
        elseif (is_object($fields))
        {
            return $this->addField($fields);
        }

        // do nothing if we get nothing
        if (empty($fields) || $fields === array('*') || $fields === array('')) { return $this; }

        // add the fields
        foreach($fields as $key => $field)
        {
            // when we have a string as key we have an alias definition
            if (is_string($key))
            {
                $this->addField($key, $field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
public function fields ( $ fields ) { // we always have to reset the fields $ this -> fields = array ( ) ; // when a string is given if ( is_string ( $ fields ) ) { $ fields = $ this -> stringArgumentToArray ( $ fields ) ; } // it also could be an object elseif ( is_object ( $ fields ) ) { return $ this -> addField ( $ fields ) ; } // do nothing if we get nothing if ( empty ( $ fields ) || $ fields === array ( '*' ) || $ fields === array ( '' ) ) { return $ this ; } // add the fields foreach ( $ fields as $ key => $ field ) { // when we have a string as key we have an alias definition if ( is_string ( $ key ) ) { $ this -> addField ( $ key , $ field ) ; } else { $ this -> addField ( $ field ) ; } } return $ this ; }
Set the selected fields fields

->fields('title')

->fields(['id', 'name'])

->fields('id, name, created_at as created')

@param array         $values
@return self The current query builder.
Set the selected fields fields