Why don't you get all of the data in one query:
<cfquery ....>
SELECT status
FROM    reservs
WHERE   room_id = #thisRoom# AND
        date_reserv BETWEEN #'x/1/xxxx'#
        AND #'x/DaysInMonth(thisDate)/xxxx'#
ORDER BY room_id, date_reserv
</cfquery>

(You may have to add the time to those dates to include all 31 days, as was
discussed earlier :)

Then loop thru the query and load it into a 2-D array?

(I think there's also a custom tag or two that dump queries into arrays, if
you don't want to hassle with doing it yourself... or, you could SELECT
status, room_id, date_reserve in the above sql, then your array code would
look like:

<cfoutput query="queryname">
<cfset arrRoom_Status[room_id][date_reserve]=status
</cfoutput>

and you wouldn't even need to ORDER BY, right?)

Eric
-----Original Message-----
From: Duane Boudreau [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 20, 2001 7:01 PM
To: CF-Talk
Subject: Reservation System


Hi All,

Talk about a need for 5.0's query a query. I need some suggestions on how to
rework this:

I am working on a room reservation system. The system is pretty basic. A
user signs in and clicks on a monthly matrix (Rooms x DaysInMonth). My
problem (see below) is that right now I end up querying for each day at the
room level to find out if its occupied which results in 15 x (28 to 31)
queries which is terribly inefficient (processing = 600 ms).

Suggestions on improvements:

<cfloop from=1 to=15 index=thisRoom>
        <cfloop from=1 to=DaysInMonth(thisDate) index=thisDay>
                <cfquery ....>
                        SELECT status
                        FROM    reservs
                        WHERE   room_id = #thisRoom# AND
                                date_reserv = #x/thisDay/xxxx#
                </cfquery>
        </cfloop>
</cfloop>

Suggestions on improvements?

Thx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to