perky416 Posted April 14, 2011 Share Posted April 14, 2011 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 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 14, 2011 Share Posted April 14, 2011 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. Quote Link to comment Share on other sites More sharing options...
perky416 Posted April 14, 2011 Author Share Posted April 14, 2011 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 Quote Link to comment 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.