Cakephp How to query the paid amount?
问题 I dont know whats wrong but my code dont output the paid amount column $payment_tbl = TableRegistry::get("MembershipPayment"); $payments = $payment_tbl->find(); $payments->select(['payment_total'=> $payments->func()->sum('paid_amount')]); $this->set("payments",$payments); and then echo this as echo $payments->payment_total; 回答1: $payments will be a query result object, not a single result. With this query, where you're expecting just a single row, add ->first() after your sum call. In general