-4
私は小さな会計アプリケーションを開発しています。以下の関数は、サプライヤのトランザクションを取得するために使用されます。私はこのループで各取引の後に残高を得たいと思っています。ある人が私に最良の方法を教えてくれますか?限界付きのランニングバランスを計算する
public function transaction_by_id_paginated($supplier_id,$start_from,$limit) {
$sql="
SELECT *
FROM transactions
WHERE tr_sup_id = $supplier_id
ORDER
BY tr_date DESC
LIMIT $start_from, $limit
";
$suppliers = DB::fetch($sql);
return $suppliers;
}
この機能では、計算された残高の値が必要です。私はDBにバランスを保存していません。
transactions
テーブルのフィールドが
tr_id (Primary) int(11)
tr_sup_id int(11)
bill_id int(11)
tr_date date
tr_type varchar(250)
tr_bill int(250)
tr_payment int(250)
tr_payment_note varchar(250)
ある私はbalance = balance + tr_payment - tr_bill
をあなたがテーブルからtr_payment' 'の合計が必要です? – AdhershMNair
いいえ、私はバランス= balance + tr_payment - tr_billと等しいバランスをしたいです –
質問で指定してください。 – AdhershMNair