Jump to content

Please help with enum


perky416

Recommended Posts

Hi guys,

 

Please forgive me if im being really stupid but i really dont get this.

 

You may have read my earlier post regarding an auction script im working on. Basically when an auction reaches its end date/time, i want to update the status of the auction automatically as soon as it ends.

 

Another script i have seen uses an enum field to set the status, and it updates the database instantly, without having to even visit the website.

 

I have tried reading up on the enum field at mysql.com however i cant seem to get my head round what it is and how it works, let alone get it to work to achieve what i am trying to do.

 

Please could somebody help me out with understanding the enum and how i can get it to work?

 

Thanks

Link to comment
Share on other sites

ENUM() is simply a definition that allow only specified values to be inserted into a field. It has nothing to do with being able to update "automatically". If you define a field as ENUM('black', 'white'), attempting to insert 'green' into the field will fail. I'm not sure why you're trying to do this at all, As long as the ending time is in the table, there should be no need to use a flag field; you can simply check if NOW() > `expires_field` to determine if it has ended.

Link to comment
Share on other sites

Hi Pikachu,

 

Im displaying the status of the auctions on a few pages on my site.

 

I did think about using something like the following as soon as the person opens the page that displays the auction status:

 

if ($date > $end_date) {
mysql_query("UPDATE auctions SET status='auction ended'");
}

 

and then echo the status on the page.

 

Is that sort of what you mean?

 

However i didn't think it was a good way to do it. Would that be perfectly acceptable? I was thinking it would be much better to automatically update the status as soon as the auction ends, even if for the admin's own benefit of the database is ever browsed through.

 

Thanks mate

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.