Cakephp How to query the paid amount?

前端 未结 1 1610
轻奢々
轻奢々 2021-01-26 15:11

I dont know whats wrong but my code dont output the paid amount column

$payment_tbl = TableRegistry::get(\"MembershipPayment\");
$payments = $payment_tbl->fin         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-26 15:31

    $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.

    0 讨论(0)
提交回复
热议问题