Click to See Complete Forum and Search --> : Timing in MySQL server


trivektor
07-25-2007, 02:50 AM
Hi,

Let say I have a Lunch database, and I want to put a constraint/restriction on an Order field so that a user can only modify their order and update the database records before some certain time, let say for example 9:30 AM. Any Update query after that will have no effect on the database. Is there a way to do it? Thanks.

bubbisthedog
07-25-2007, 03:05 PM
[I'm assuming that you're using PHP, but the following logic will work no matter what language you're writing in...]

Untested, but you should get the idea (by the way, this is a PHP-related answer, not really SQL):

$max_time = '9:30:00';
if (curtime() < $max_time) {
::update query goes here::
}

If you wanted to use an SQL solution, I'd suggest researching triggers.