public function fields($fields, $context) {
		$type = $context->type();
		$schema = $context->schema()->fields();
		$alias = $context->alias();

		if (!is_array($fields)) {
			return $this->_fieldsReturn($type, $context, $fields, $schema);
		}

		$context->applyStrategy($this);
		$fields = $this->_fields($fields ? : $context->fields(), $context);
		$context->map($this->_schema($context, $fields));
		$toMerge = [];

		if (isset($fields[0])) {
			foreach ($fields[0] as $val) {
				$toMerge[] = (is_object($val) && isset($val->scalar)) ? $val->scalar : $val;
			}
			unset($fields[0]);
		}

		$fields = isset($fields[$alias]) ? [$alias => $fields[$alias]] + $fields : $fields;

		foreach ($fields as $field => $value) {
			if (is_array($value)) {
				if (isset($value['*'])) {
					$toMerge[] = $this->name($field) . '.*';
					continue;
				}
				foreach ($value as $fieldname => $mode) {
					$toMerge[] = $this->_fieldsQuote($field, $fieldname);
				}
			}
		}

		return $this->_fieldsReturn($type, $context, $toMerge, $schema);
	}
public function fields($fields, $context) {
		$type = $context->type();
		$schema = $context->schema()->fields();
		$alias = $context->alias();

		if (!is_array($fields)) {
			return $this->_fieldsReturn($type, $context, $fields, $schema);
		}

		$context->applyStrategy($this);
		$fields = $this->_fields($fields ? : $context->fields(), $context);
		$context->map($this->_schema($context, $fields));
		$toMerge = [];

		if (isset($fields[0])) {
			foreach ($fields[0] as $val) {
				$toMerge[] = (is_object($val) && isset($val->scalar)) ? $val->scalar : $val;
			}
			unset($fields[0]);
		}

		$fields = isset($fields[$alias]) ? [$alias => $fields[$alias]] + $fields : $fields;

		foreach ($fields as $field => $value) {
			if (is_array($value)) {
				if (isset($value['*'])) {
					$toMerge[] = $this->name($field) . '.*';
					continue;
				}
				foreach ($value as $fieldname => $mode) {
					$toMerge[] = $this->_fieldsQuote($field, $fieldname);
				}
			}
		}

		return $this->_fieldsReturn($type, $context, $toMerge, $schema);
	}
public function fields ( $ fields , $ context ) { $ type = $ context -> type ( ) ; $ schema = $ context -> schema ( ) -> fields ( ) ; $ alias = $ context -> alias ( ) ; if ( ! is_array ( $ fields ) ) { return $ this -> _fieldsReturn ( $ type , $ context , $ fields , $ schema ) ; } $ context -> applyStrategy ( $ this ) ; $ fields = $ this -> _fields ( $ fields ? : $ context -> fields ( ) , $ context ) ; $ context -> map ( $ this -> _schema ( $ context , $ fields ) ) ; $ toMerge = [ ] ; if ( isset ( $ fields [ 0 ] ) ) { foreach ( $ fields [ 0 ] as $ val ) { $ toMerge [ ] = ( is_object ( $ val ) && isset ( $ val -> scalar ) ) ? $ val -> scalar : $ val ; } unset ( $ fields [ 0 ] ) ; } $ fields = isset ( $ fields [ $ alias ] ) ? [ $ alias => $ fields [ $ alias ] ] + $ fields : $ fields ; foreach ( $ fields as $ field => $ value ) { if ( is_array ( $ value ) ) { if ( isset ( $ value [ '*' ] ) ) { $ toMerge [ ] = $ this -> name ( $ field ) . '.*' ; continue ; } foreach ( $ value as $ fieldname => $ mode ) { $ toMerge [ ] = $ this -> _fieldsQuote ( $ field , $ fieldname ) ; } } } return $ this -> _fieldsReturn ( $ type , $ context , $ toMerge , $ schema ) ; }
Returns a string of formatted fields to be inserted into the query statement.

@param array $fields Array of fields.
@param object $context Generally a `data\model\Query` instance.
@return string A SQL formatted string
Returns a string of formatted fields to be inserted into the query statement .