Subselect and sum row

Subselect() will create a new column with some value from other (or current) table. You can use any columns from current tables as parameters. Subselect will be called for each row

HIDE CODE
<?php
	$xcrud = Xcrud::get_instance();
    $xcrud->table('customers');
    $xcrud->columns('customerName,city,creditLimit,Paid,Profit'); // specify only some columns
    $xcrud->subselect('Paid','SELECT SUM(amount) FROM payments WHERE customerNumber = {customerNumber}'); // other table
    $xcrud->subselect('Profit','{Paid}-{creditLimit}'); // current table
    $xcrud->sum('creditLimit,Paid,Profit'); // sum row(), receives data from full table (ignores pagination)
    $xcrud->change_type('Profit','price','0',array('prefix'=>'$')); // number format
    echo $xcrud->render();
?>

Customers

#CustomernameCityCreditlimitPaidProfit
Actions
1Atelier graphicsNantes51000014191.12$-495,808.88 View Edit Remove
2Australian Collectors, Co.Melbourne117300$0.00 View Edit Remove
3Baane Mini ImportsStavern81700$0.00 View Edit Remove
4Mini Gifts Distributors Ltd.San Rafael210500$0.00 View Edit Remove
5Zbyszek Zbyszek PiestrzeniewiczWarszawa1230$0.00 View Edit Remove
6Blauer See Auto, Co.Frankfurt59700$0.00 View Edit Remove
7Mini Wheels Co.San Francisco64600$0.00 View Edit Remove
8Land of Toys Inc.NYC114900$0.00 View Edit Remove
9Euro+ Shopping ChannelMadrid227600147968.93$-79,631.07 View Edit Remove
10Volvo Model Replicas, CoLuleå5310043680.65$-9,419.35 View Edit Remove
Σ  8464130.1200000016742277.290000002$-1,071,922.83 
Search