Hello Community,
I have a DB query with sum
PHP Code:
$this->Database->prepare("SELECT SUM(money) FROM `tl_finance_transactions` WHERE headcategory = ? AND `subcategory` = ? AND YEAR(FROM_UNIXTIME(`transactionsdate`)) = ? AND MONTH(FROM_UNIXTIME(`transactionsdate`)) = ? AND `client` = ?")->execute($headcategory,$subcategory,$year,$month,$UserId)->next();
When i dump the results i get :
PHP Code:
Contao\Database\Mysqli\Result Object ( [resResult:protected] => mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => Array ( [0] => 6 ) [num_rows] => 1 [type] => 0 ) [strQuery:protected] => SELECT SUM(money) FROM `tl_finance_transactions` WHERE headcategory = 1 AND `subcategory` = 's,13' AND YEAR(FROM_UNIXTIME(`transactionsdate`)) = '2015' AND MONTH(FROM_UNIXTIME(`transactionsdate`)) = 1 AND `client` = '1' [intIndex:Contao\Database\Result:private] => 0 [blnDone:Contao\Database\Result:private] => [blnModified:Contao\Database\Result:private] => [arrCache:protected] => Array ( [SUM(money)] => 180.00 ) )
but when i whant the data "[SUM(money)]" i do
PHP Code:
return $test->SUM(money)
only i get a error "Fatal error: Uncaught exception Error with message Call to undefined method Contao\Database\Mysqli\Result::SUM()"
How can i get the data "[SUM(money)]"
Thanks in advance
Bookmarks