protected function _subqueryFields($query)
    {
        $keys = (array)$this->bindingKey;

        if ($this->associationType === Association::MANY_TO_ONE) {
            $keys = (array)$this->foreignKey;
        }

        $fields = $query->aliasFields($keys, $this->sourceAlias);
        $group = $fields = array_values($fields);

        $order = $query->clause('order');
        if ($order) {
            $columns = $query->clause('select');
            $order->iterateParts(function ($direction, $field) use (&$fields, $columns) {
                if (isset($columns[$field])) {
                    $fields[$field] = $columns[$field];
                }
            });
        }

        return ['select' => $fields, 'group' => $group];
    }
protected function _subqueryFields($query)
    {
        $keys = (array)$this->bindingKey;

        if ($this->associationType === Association::MANY_TO_ONE) {
            $keys = (array)$this->foreignKey;
        }

        $fields = $query->aliasFields($keys, $this->sourceAlias);
        $group = $fields = array_values($fields);

        $order = $query->clause('order');
        if ($order) {
            $columns = $query->clause('select');
            $order->iterateParts(function ($direction, $field) use (&$fields, $columns) {
                if (isset($columns[$field])) {
                    $fields[$field] = $columns[$field];
                }
            });
        }

        return ['select' => $fields, 'group' => $group];
    }
protected function _subqueryFields ( $ query ) { $ keys = ( array ) $ this -> bindingKey ; if ( $ this -> associationType === Association :: MANY_TO_ONE ) { $ keys = ( array ) $ this -> foreignKey ; } $ fields = $ query -> aliasFields ( $ keys , $ this -> sourceAlias ) ; $ group = $ fields = array_values ( $ fields ) ; $ order = $ query -> clause ( 'order' ) ; if ( $ order ) { $ columns = $ query -> clause ( 'select' ) ; $ order -> iterateParts ( function ( $ direction , $ field ) use ( & $ fields , $ columns ) { if ( isset ( $ columns [ $ field ] ) ) { $ fields [ $ field ] = $ columns [ $ field ] ; } } ) ; } return [ 'select' => $ fields , 'group' => $ group ] ; }
Calculate the fields that need to participate in a subquery.

Normally this includes the binding key columns. If there is a an ORDER BY,
those columns are also included as the fields may be calculated or constant values,
that need to be present to ensure the correct association data is loaded.

@param \Cake\ORM\Query $query The query to get fields from.
@return array The list of fields for the subquery.
Calculate the fields that need to participate in a subquery .