我正在使用下面的代码来总结我所有的钱包余额。
$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;
出局pj($query);
[
{
"count": 2,
"total_price": 700
}
]
在这里,我尝试使用以下查询获取单个值
echo $query->total_price;
我不明白。什么是正确的语法,请建议我。谢谢。