On Friday, September 21, 2018 at 9:54:00 AM UTC-7, mostwanted wrote: > > How do i get a value stored in the database to be selected only once by > users? I am creating a hotel system and in this system i have to make sure > that a room can not be double booked, it can only be selected once for one > client. > > Regards > > Mostwanted >
There are a couple of ways I can think of. The most obvious way would to be include a boolean field in your room record, call it "available". db.define_table('room', Field('available', 'string'), Field('roomnum', 'integer'), Field('numsleeps', 'integer'), Field('occupant', refence 'account')) Your controller function that assigns the room to an occupant would update both fields, but only if 'available' was True when fetched. This relies on the web2py default that an http request is performed as a single transaction. /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.