I use this code below to summarize the whole balance of my wallet.
$query = $this->Wallets->find();
$query->select([
'count' => $query->func()->count('id'),
'total_price' => $query->func()->sum('amount')
])
->where(['status' => 4, 'user_id' => $user_id]);
pj($query);
echo $query->total_price;
exit;
out put of pj($query);
[
{
"count": 2,
"total_price": 700
}
]
Here I tried to get a separate individual value using the following query
echo $query->total_price;
I do not understand. What is the correct syntax, plz suggest me. Thanx.
source
share