The page is only 4K but it can sometimes take 10 seconds to appear. I did some checking and it is for sure the length of time for the DB to return the results. I open the DB connection, run the double loops, and then close the connection so it is not opening and closing in each loop.
When I asked someone who knows these things what he thought I should do, he said "Don't really have time to look at this in detail. Could probably be done faster in a function in the db for a bunch of it."
Great, but now I have to figure out how to create a function in the DB, in PostgreSQL in particular.
There are 3 SQL calls in the loops:
SELECT id FROM calendar WHERE prop_num=:id AND (check_in=':year/:month/:day')
If the record is not empty, it returns a "checked-in" image.
SELECT id FROM calendar WHERE prop_num=:id AND (check_out=':year/:month/:day')
If the record is not empty, and there has already been a return for the previous SQL call, it returns a "booked" image, otherwise it returns a "checked-out" image.
SELECT id FROM calendar WHERE prop_num=:id AND (':year/:month/:day' > check_in) AND (':year/:month/:day' < check_out)
Returns a "booked" image.
So the question is, how would I create a Function in the DB to handle some of this stuff internally? Any advice would be greatly appreciated.


Sign In
Create Account


Back to top









