src/Widgets/ReportWidget.php
public function getQueryData(array $config = []) : array
    {
        if (empty($config)) {
            return [];
        }

        $resultSet = [];

        if (!empty($config['info']['finder'])) {
            $table = $config['info']['model'];

            $finder = $config['info']['finder']['name'];
            $options = Hash::get($config, 'info.finder.options', []);

            $resultSet = TableRegistry::get($table)->find($finder, $options);
        }

        if (empty($config['info']['finder']) && !empty($config['info']['query'])) {
            $resultSet = ConnectionManager::get('default')
                ->execute($config['info']['query'])
                ->fetchAll('assoc');
        }

        $columns = explode(',', $config['info']['columns']);

        $result = [];
        foreach ($resultSet as $item) {
            $row = [];
            foreach ($item as $column => $value) {
                if (in_array($column, $columns)) {
                    $row[$column] = $value;
                }
            }
            array_push($result, $row);
        }

        return $result;
    }
public function getQueryData(array $config = []) : array
    {
        if (empty($config)) {
            return [];
        }

        $resultSet = [];

        if (!empty($config['info']['finder'])) {
            $table = $config['info']['model'];

            $finder = $config['info']['finder']['name'];
            $options = Hash::get($config, 'info.finder.options', []);

            $resultSet = TableRegistry::get($table)->find($finder, $options);
        }

        if (empty($config['info']['finder']) && !empty($config['info']['query'])) {
            $resultSet = ConnectionManager::get('default')
                ->execute($config['info']['query'])
                ->fetchAll('assoc');
        }

        $columns = explode(',', $config['info']['columns']);

        $result = [];
        foreach ($resultSet as $item) {
            $row = [];
            foreach ($item as $column => $value) {
                if (in_array($column, $columns)) {
                    $row[$column] = $value;
                }
            }
            array_push($result, $row);
        }

        return $result;
    }
public function getQueryData ( array $ config = [ ] ) : array { if ( empty ( $ config ) ) { return [ ] ; } $ resultSet = [ ] ; if ( ! empty ( $ config [ 'info' ] [ 'finder' ] ) ) { $ table = $ config [ 'info' ] [ 'model' ] ; $ finder = $ config [ 'info' ] [ 'finder' ] [ 'name' ] ; $ options = Hash :: get ( $ config , 'info.finder.options' , [ ] ) ; $ resultSet = TableRegistry :: get ( $ table ) -> find ( $ finder , $ options ) ; } if ( empty ( $ config [ 'info' ] [ 'finder' ] ) && ! empty ( $ config [ 'info' ] [ 'query' ] ) ) { $ resultSet = ConnectionManager :: get ( 'default' ) -> execute ( $ config [ 'info' ] [ 'query' ] ) -> fetchAll ( 'assoc' ) ; } $ columns = explode ( ',' , $ config [ 'info' ] [ 'columns' ] ) ; $ result = [ ] ; foreach ( $ resultSet as $ item ) { $ row = [ ] ; foreach ( $ item as $ column => $ value ) { if ( in_array ( $ column , $ columns ) ) { $ row [ $ column ] = $ value ; } } array_push ( $ result , $ row ) ; } return $ result ; }
Retrieve Query data for the report

Executes Query statement from the report.ini
to retrieve actual report resultSet.

@param mixed[] $config of the report.ini
@return mixed[] $result containing required resultset fields.
Retrieve Query data for the report