To start, you really need two tables. This is a very simple example.
Look in the simple examples code for dogs and owners to get the whole
story about one-to-many relationships. Also there is more information
in the on-line manual in the database chapter.
db.define_table('rooms',
Field('room_number')
)
db.define_table('bookings',
Field('room_id', db.rooms),
Field('booking_start', 'datetime'),
Field('booking_end', 'datetime'),
)
Look in the booking example code, I'm sure you will see something
similar...
I would also point you to the booking examples to see how double
bookings are prevented.
On Feb 28, 2:28 pm, Christoph Ott <[email protected]> wrote:
> Thank you for the great examples, helped me a lot.
>
> It's almost working I've got only a few Problems...
>
> My DB has 3 fields: Room, time, date.
> Is there any possibility to check if the room already booked? So I
> can't book a room twice
> I've found nothing in the book and with google.
> Can you give me hint what command it can probably work?
>
> Thanks a lot
>
> On 22 Feb., 18:53, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Here
>
> >http://web2py.com/appliances
>
> > you can find some reservation systems: hotelroom, restaurant table,
> > books.
>
> > Hope they are useful.
>
> > Massimo
>
> > On Feb 22, 10:37 am, Christoph Ott <[email protected]>
> > wrote:
>
> > > Hello,
>
> > > first of all I'm a beginner with web2py... I have to realize aroombooking
> > > system with web2py for my study.
> > > For now I've created a table called db.bookings this table got the values:
> > > id, user,room, time, date... (theroomare from an other table called
> > > db.room)
>
> > > To allow the user to check if theroomis available on a certain time I
> > > wanted to make a field where he can choose aroomand get the bookings for
> > > thisroomdisplayed... I've tried a lot with crud.select but I didn't found
> > > any useful examples with google and in the web2py book
> > > (http://web2py.com/book/default/chapter/07#CRUD) isn't much explained...
>
> > > can anyone give me a hint or just a good site with some examples how I
> > > could realize this function.
> > > Thanks a lot for reading...
>
> > > bye