lithium\data\source\Database::_fieldsReturn PHP Method

_fieldsReturn() protected method

Renders the fields SQL fragment for queries.
See also: lithium\data\source\Database::fields()
protected _fieldsReturn ( string $type, object $context, array $fields, array $schema ) : string | array
$type string Type of query i.e. `'create'` or `'update'`.
$context object Generally a `data\model\Query` instance.
$fields array
$schema array An array defining the schema of the fields used in the criteria.
return string | array
    protected function _fieldsReturn($type, $context, $fields, $schema)
    {
        if ($type === 'create' || $type === 'update') {
            $data = $context->data();
            if (isset($data['data']) && is_array($data['data']) && count($data) === 1) {
                $data = $data['data'];
            }
            if ($fields && is_array($fields) && is_int(key($fields))) {
                $data = array_intersect_key($data, array_combine($fields, $fields));
            }
            $method = "_{$type}Fields";
            return $this->{$method}($data, $schema, $context);
        }
        return empty($fields) ? '*' : join(', ', $fields);
    }