Skip to content

Aggregation and Reports

Romans Malinovskis edited this page Apr 18, 2016 · 1 revision

Ability to create reports is probably one of the most complex areas where many data access libraries fall short and prove to be absolutely useless to do anything else other than execute a stored procedure.

The problem we solve with Reports is that we allow you to create your report directly from your Business Models. We already know how to convert them into queries and we are pretty good at manipulating queries so let's see what we can do:

Aggregating

$client_aggregate = $client->aggregate();
$client_aggregate->groupBy('age');
$client_aggregate->addSum('completed_orders,total_orders');
$client_aggregate->addFx('avg','amm',$client->getElement('amount'));
    // example of manual function definition

Union

$all_users = $db->add(new atk4\data\Union());
$all_users->addModel('Client');
$all_users->addModel('Admin');