I am new to mysql I am using phpmyadmin 5.1.43. User perform transaction lets say he reserve a seat and i want that after 48 hours of reservation if he does not pay for reservation his reservation should automatically be cancelled?? how would i do it?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Deleting rows after X amount of time is not the relational way of tackling this kind of problem. Rather you would want to add enough data into the tables so that you can query it and get the result you want.
Ie. add a column "expire_at" or similiar as a datetime, and when you query the table add a clause
WHERE expire_at < NOW()
You can even add this to a view which you can then query in an easier way.
You could do it everytime someone asks for a reservation. If the seat is already reserved by someone, and the timestamp of reservation is registered on a specific column, you could get the "age" of the reservation by comparing it with the current date:
(I choose the function
now()
to illustrate the point, you would replacenow()
with the name of the specific column.). Then, if it is overdue, you let the new reservation override the previous one.There are several possible approaches. Which you choose depends on system considerations: