Pages::selectSum($select)

Version 2024.2

Select sum of given field

Duration and time -fields return sum as hh:mm:ss

Return value

Float,Array

Arguments

$select
String Field name or select -definition
Array name=>field. If field is empty, uses name as field.

Full documentation

Get total amount of new projects:

$totalAmount = $this->get('pages','project')
    ->addWhere('status','New')
    ->selectSum('total_amount');

--- result
$totalAmount = 100.00;

Get total amount and hours estimate of new projects:

$total = $this->get('pages','project')
    ->addWhere('status','New')
    ->selectSum(Array(
        'total_amount' => '',
        'hours' => 'hours_estimate'
    ));

--- result
$total = Array(
    'total_amount' => 100.00,
    'hours' => 03:45:00'
);