I have a table called users which currently contains column money of type integer which contains the amount of money the user currently has.
However, I would like to expand and have a couple of more currencies that are based on each other. 1 Gold = 10 Silver = 100 Bronze (or something like that). When you get 100 Bronze, they will convert into 1 Gold. The same with 10 Bronze = 1 Silver. All these currencies have their own column in my table. I have a hook function that is called on every request and updates the money, if possible.
I was told though I could use just one column money and then I can play with variables and take out the different currencies.
But my question is: What would be the best method?
In case the latter method is best: How do I put variables to an already existing object (an object which contains user data; I think it’s called stdClass or something like that)? $user->username, etc.?
Just store the equivalent number of bronze. Then use the following algorithm to get as much as possible converted to gold, from the remainder as much as possible to silver and the rest stays in bronze:
So if you have 9,327 bronze: