Jump to content

[SOLVED] Interactive Site - Limiting game plays per day?


Nikker

Recommended Posts

I've been working off and on on an interactive site for a while now (think something like Neopets or Gaia), and I'm wondering what the best way to go about keeping track of how many times in a day each user has played each of the games (which there's only one of, thus far).

 

I'm fairly new with PHP and MySQL.

 

Thinking about the issue, I've considered a couple of possible ways to do this - but I'm not sure which would stress the server most, or be the most efficient.

 

My first idea, which seems to me to be unnecessarily complicated, was to add a new field for each game in the user table of the database, and have this reset daily by crons.

 

My second, more recent idea, is that I could create a "game plays" table in the database, and every time a user submits a game score a row is added which specifies the username and which game was played.  This entire table would be cleared daily by crons, as well.  I'm just not sure if consistently adding and removing rows from a table is stressful to the database, or not.

 

 

Are there any better ways I should be going about this, or am I on the right track?  I appreciate any feedback very much.

 

Thank you.

Link to comment
Share on other sites

Second works for me, due the limited data, thats should NOT be too stressfull on the system..

i would probably have a table with ID, UserID, GameID & DateStamp then you can check like

SELECT count(*) as TimesPlayed WHERE UserID=$uID AND GameID=$gID AND DateStamp=CURDATE();

.. at the end on the week/month you could just use TRUNCATE TABLE, to clean it up (for a quickness)

 

EDIT: missed the NOT.. LOL

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.