Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My booking system currently allows users to delete bookings at any time. The system should restrict the users from deleting bookings at a certain time for instance 24 hours before the booking date. Users should only be able to delete bookings 48 prior to booking date. Is there any way of doing this.

current sql statement

$query1="DELETE from bookings1 where booking_id='$id'";

$results = $mysqli->query($query1);

would i need to use some function or something
Posted
Comments
ZurdoDev 4-Mar-15 14:45pm    
Yes, you need to add some logic before calling delete.
Member 11498880 4-Mar-15 15:04pm    
is there any method of doing this

1 solution

IMHO the database would be the best place for this logic since the data is then safe regardless what application tries to modify the data.

In order to do that, I'd write a TRIGGER for DELETE and check if the row being deleted shouldn't be allowed to. In such case I'd raise an error.

For more information, see 13.1.11 CREATE TRIGGER Syntax[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900