Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2007, 10:19 PM   PM User | #1
sayeed
New to the CF scene

 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sayeed is an unknown quantity at this point
Help Plz Anyone

Hi i need a bit of help

i am creating a hotel reservation system using php and mysql. one of the criteria of the system is to prevent double booking taking place for example if 2 users book only one room which is availbele, then only one person should be allowed to get that.

i dont know if u am right in using a lock function please some one tell me how to use that to control concurrency
sayeed is offline   Reply With Quote
Old 02-01-2007, 04:28 AM   PM User | #2
Len Whistler
Senior Coder

 
Len Whistler's Avatar
 
Join Date: Jul 2002
Location: Vancouver, BC Canada
Posts: 1,323
Thanks: 26
Thanked 100 Times in 100 Posts
Len Whistler is on a distinguished road
Have a room_number and booked table in the MySQL database. The room_number table would hold all the room numbers, and the booked table could hold some booking information when the form is submitted.

Your webpage would run a query and display only the rows that have no information in the booked table. So if room 234 is booked it doesn't show up, if the reservation is cancelled then the booked table becomes empty and will then display the room as being available.
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Old 02-01-2007, 05:35 AM   PM User | #3
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Please post helpful thread titles. if everyone posted such titles, the forum would be useless as to figure out what threads were about what.

to answer your question see the link in my signature.
guelphdad is offline   Reply With Quote
Old 02-01-2007, 07:44 AM   PM User | #4
gunman
New Coder

 
Join Date: Jul 2005
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
gunman is an unknown quantity at this point
It depend on your database structure basically you could use like that
PHP Code:
LOCK TABLES trans READcustomer WRITE;
select sum(valuefrom trans where customer_idsome_id;
update customer set total_value=sum_from_previous_statement
           where customer_id
=some_id;
UNLOCK TABLES
__________________
If you can not find a decision, maybe you have to try to change a problem

http://www.gunman.co.nr
http://bglinux.org
gunman is offline   Reply With Quote
Old 02-01-2007, 01:10 PM   PM User | #5
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Quote:
Originally Posted by gunman View Post
It depend on your database structure basically you could use like that
PHP Code:
LOCK TABLES trans READcustomer WRITE;
select sum(valuefrom trans where customer_idsome_id;
update customer set total_value=sum_from_previous_statement
           where customer_id
=some_id;
UNLOCK TABLES
Have you posted in the right thread? This doesn't seem to answer the OPs question.
guelphdad is offline   Reply With Quote
Old 02-05-2007, 03:55 PM   PM User | #6
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
Quote:
Originally Posted by guelphdad View Post
to answer your question see the link in my signature.
The link in your signature has been a real life saver for the past couple of weeks. I wouldn't be surprised if it answered 50% of the questions posted in this forum. Well done on the links Guelphdad.
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:00 AM.


Advertisement
Log in to turn off these ads.