I dont know whats wrong but my code dont output the paid amount column
$payment_tbl = TableRegistry::get(\"MembershipPayment\");
$payments = $payment_tbl->fin
$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, if you're not getting what you expect, dump the contents of the variable in question, like with pr($payments)
or debug($payments)
, that will very often very quickly give you a clear indication of what the problem is. In this case, you'll see it's not the Entity object that you're expecting.