auto table update in sql hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Mahmud
Posts: 12
Joined: 2017-03-12 08:53

auto table update in sql hook

Post by Mahmud » 2017-05-04 14:54

i have two table

1. FUNDED_TRANSACTION when BALANCE update
2. FUNDED_BANK_SUMMARY then this table BALANCE update
function FUNDED_BANK_SUMMARY_before_insert(&$data, $memberInfo, &$args){
$data['AVAILABLE_BALANCE'] = $data['LOAN_LIMIT'] - $data['BALANCE'];

by hook work ok....

but problem is when FUNDED_TRANSACTION BALANCE update then FUNDED_BANK_SUMMARY this table BALANCE not auto update .

how can i do
Attachments
Untitled.jpg
Untitled.jpg (255.01 KiB) Viewed 2645 times

Mahmud
Posts: 12
Joined: 2017-03-12 08:53

Re: auto table update in sql hook

Post by Mahmud » 2017-05-13 19:41

solved :
---------------
if($ACCOUNT_NAME){
$ACCOUNT_NAME_BALANCE = sqlValue("select sum(if(TRANSACTION_TYPE in ({$positive_funded_transaction}), BALANCE, -1 * BALANCE)) from funded_transaction where ACCOUNT_NAME={$ACCOUNT_NAME}");
sql("update funded_bank_summary set BALANCE='{$ACCOUNT_NAME_BALANCE}' where id={$ACCOUNT_NAME}", $eo);
mysql_select_db('bank',mysql_connect('localhost','bank',''))or die(mysql_error());
$query=mysql_query("select * from FUNDED_BANK_SUMMARY where id={$ACCOUNT_NAME} ")or die(mysql_error());
$row=mysql_fetch_array($query);
$ALANCE=$row['LOAN_LIMIT']- $row['BALANCE'];
sql("UPDATE FUNDED_BANK_SUMMARY SET AVAILABLE_BALANCE= '{$ALANCE}' where id={$ACCOUNT_NAME}", $eo);

}

Post Reply