Jump to content

A Bank


The Little Guy

Recommended Posts

I am building a "Fake" bank, when a user signs up, he/she starts out with a $500,000 loan from the bank. He/she then can buy or sell stuff, and each transaction will be stored in a table in the database.

 

I am wondering, will I get an accurate user balance if I use mysql SUM on ALL of the users transactions?

 

SELECT SUM(`amount`) as loanSum FROM bank WHERE owner = '$this->owner' AND (type='l' OR type='d' OR type='w')

 

type l = loan

type d = deposit

type w = withdrawal (this contains a negative value such as: -400)

Link to comment
https://forums.phpfreaks.com/topic/158318-a-bank/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.