Hi all

I am trying to create the following SQL as a PROPEL criteria to sit in the 
Bookings model.

Details are:

Schema------
  booking: 
    id: ~
    client_id:  integer
    room_id:    integer
    start_date: date
    end_date:   date
    adults:     integer
    children:   integer
    created_at: timestamp
  client: 
    id: ~
    name:       varchar(128)
    created_at: timestamp
  room: 
    id: ~
    name:       varchar(128)
    price:      decimal
    bed:        integer
    created_at: timestamp


SQL-----
[with checkDate being the date to be checked that is passed from the view]

 SELECT room_id, 'Y' AS booked FROM booking
   WHERE checkDate BETWEEN start_date AND end_date
 UNION 
  SELECT id AS room_id, 'N' AS booked FROM room
    WHERE id NOT IN ( 
      SELECT room_id FROM booking
        WHERE checkDate BETWEEN start_date AND end_date 
    )
 ORDER BY room_id

The eventual purpose is to display a table in the view with rooms and dates 
booked:
          Room
Date      101  102  103  201  202  203
20080612    Y    N    Y    N    Y    N
20080613    Y    N    N    N    Y    Y
20080614    N    Y    Y    N    Y    Y
20080615    N    N    Y    N    Y    N


Now I am making an assumption that this is best placed in the Booking.php file 
in lib/model so that results are available to more than one controller.

I am not that familiar with PROPEL yet, so help is appreciated.

Once I have this little application working I am aiming to provide it to the 
symfony community as a tutorial via our IT web site, so help will be credited 
both here and in the articles.

Adrian
---
Adrian Gould
Lecturer in IT / Network Engineering / Multimedia
Business Finance & Computing [Midland Campus]
Swan TAFE
PO BOX 1336, Midland WA 6936

Phone: (08) 9267 7777
eMail: [EMAIL PROTECTED]



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to