Nikker Posted October 24, 2007 Share Posted October 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/74656-solved-interactive-site-limiting-game-plays-per-day/ Share on other sites More sharing options...
MadTechie Posted October 24, 2007 Share Posted October 24, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74656-solved-interactive-site-limiting-game-plays-per-day/#findComment-377377 Share on other sites More sharing options...
Nikker Posted October 24, 2007 Author Share Posted October 24, 2007 Oh, thank you. I'll see how that goes, then. Quote Link to comment https://forums.phpfreaks.com/topic/74656-solved-interactive-site-limiting-game-plays-per-day/#findComment-377380 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.