Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6916907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:39:48+00:00 2026-05-27T09:39:48+00:00

I have a table called users which currently contains column money of type integer

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:39:48+00:00Added an answer on May 27, 2026 at 9:39 am

    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:

    1. Set the number of gold to zero, silver to zero and bronze to whatever the database says.
    2. Set the number of silver equal to the number of bronze divided by 10 (use integer division). Set the number of bronze equal to the number of bronze mod 10.
    3. Set the number of gold equal to the number of silver divided by 10 (use integer division). Set the number of silver equal to the number of silver mod 10.

    So if you have 9,327 bronze:

    1. gold=0, silver=0, bronze=9,327
    2. gold=0, silver=932, bronze=7
    3. gold=93, silver=2, bronze=7
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a table called User which has a id column which is
I have a table called Users ( class User < ActiveRecord::Base ) and a
I have a table called ApprovalTasks... Approvals has a status column I also have
I have a table called BlogPost which has a 1-to-many relationship with the Comment
I have a table called Classes which stores information on College classes. It has
Learning php! I have a sql database which contains a table called 'images' which
I have an entity called User which can have a list of other Users
I have a table which contains around 400 000 records and which gets called
Given a Database that has a table Called [Bid Transactions], which contains records of
I have a table called UserPermissions with a FK to the users table by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.