Jump to content

Change status of user every 12:00am


KaiSheng
Go to solution Solved by requinix,

Recommended Posts

Hi all again!!

 

I will describe the game first.

According to my game, the person who plays the game will click on a "play" button, and status of the user will change from

available to played.

 

So, according to my query, i used "UPDATE users SET status ='played'"

I want to include something more.

anyone know how to include the query for the status to auto change (from played to available) every 12:00am (GMT+8 ) ?

 

Greatly appreciated for all comments.

:)

Edited by KaiSheng
Link to comment
Share on other sites

9/10 times if you want to update something in a database at a certain time, like for "resetting" something or updating a counter, there's a smarter way of going about it.

 

In this case the smarter way is just keeping track of the last time they played. If they played played today then they're not available, otherwise (if they played sometime before today) then they are available.

Link to comment
Share on other sites

I do not know how to include the date they played. Because it's an update query, so the field must not be empty.

For example, using INSERT query, the field in database must be empty before this will work.

using UPDATE query, the field in database must not be empty.

I have no idea how this is gonna work using date timestamp, although I know this is an easier way.

Link to comment
Share on other sites

  • Solution

It would be a timestamp instead of the status field. Update it to the current time when they play.

When you want to know who/whether someone is available, look at that timestamp: if it comes from today then they're not available, otherwise they are.

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.