Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:30:28+00:00 2026-06-17T21:30:28+00:00

I am creating a room reservation in php. I have two tables: table RESERVE

  • 0

I am creating a room reservation in php.

I have two tables:

table RESERVE

  • reserve_id
  • room_id
  • room_reserve_qty
  • checkout

table ROOM

  • room_id
  • room_qty

when the “checkout” date reached the date today,that row in the reserve table will be deleted.Actually I already have the event for that :

DROP EVENT `auto_delete_chckout`;
CREATE DEFINER=`root`@`localhost` 
EVENT `auto_delete_chckout` 
ON SCHEDULE EVERY 1 MINUTE STARTS '2013-01-26 13:09:15' 
ON COMPLETION NOT PRESERVE ENABLE DO 
DELETE FROM reserve WHERE checkout <= CURDATE()

so my question is :

If a reservation is being deleted , its room_reserve_qty must be added in the room_qty in room table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:30:29+00:00Added an answer on June 17, 2026 at 9:30 pm

    First of all you probably don’t need to fire your event every minute, since you check only for a date part. You might want to do that once a day.

    Secondly I would put updating room_qty logic in a trigger. That way no matter how you delete your reservation, your room_qty will be correct.

    Your trigger might look like this

    DELIMITER $$
    
    CREATE TRIGGER reserve_before_delete BEFORE DELETE ON reserve
        FOR EACH ROW BEGIN
            UPDATE room
               SET room_qty = room_qty + OLD.room_reserve_qty 
             WHERE room_id = OLD.room_id;
        END;
    $$
    
    DELIMITER ;
    

    Your DELETE code stays intact when you use a trigger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a room suggestion feature for a room reservation system and I'm trying
I am creating a room reservation system. So i want to make selectable only
I'm creating an initialising function for the class 'Room', and found that the program
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Scenario : Creating a server which has Room objects which contain User objects. I
im creating a 3d room which you can walk around with a first person
Let's say you're creating a database to store messages for a chat room application.
I am creating a bouncing object that can bounce around a 2D rectangular room.
I am creating a maze game. For that I have created 4 separate class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.