Getting an array instead of number

Hello everybody,
I’m doing some changes on a clients website but i’m not experienced php developer.
I’m trying to get total of values of a column called “amount” in a table called “withdraws”
I have this code:

$totalWithdrawls = $this->Users->Withdraws->find()->sumOf(‘amount’);

Which return the content as an array (5,10,15,20)
I want to get the total of them (50) as a number.
how to achieve that?

Thank you in advance.

http://php.net/manual/en/function.array-sum.php

Thank you sir, my code worked perfectly with no changes at all !!!
I do not know what happened yesterday!!

Sounds like some kind of cache (eg. OPCache) might have been causing this error? :slight_smile:

To be honest, i have no idea what happened exactly !!!

Ah yes, the programmer dillemma: “it doesn’t work, I have no clue why; it works, I have no clue why”

2 Likes